--
-- Host: localhost    Database: anteckningar
-- ------------------------------------------------------


--
-- Current Database: `anteckningar`
--

CREATE DATABASE /*!32312 IF NOT EXISTS*/ `anteckningar` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci */;

USE `anteckningar`;

--
-- Table structure for table `checklist_items`
--

CREATE TABLE `checklist_items` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `note_id` int(11) NOT NULL,
  `text` varchar(500) NOT NULL DEFAULT '',
  `checked` tinyint(1) NOT NULL DEFAULT 0,
  `position` int(11) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  KEY `idx_items_note` (`note_id`),
  CONSTRAINT `fk_note` FOREIGN KEY (`note_id`) REFERENCES `notes` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `checklist_items`
--

INSERT INTO `checklist_items` VALUES
(1,1,'testa servern',0,0),
(2,1,'kolla att mail fungerar',0,1),
(3,1,'kolla så totp fungerar',1,2);

--
-- Table structure for table `login_logs`
--

CREATE TABLE `login_logs` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(60) NOT NULL,
  `ip` varchar(45) NOT NULL,
  `success` tinyint(1) NOT NULL,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_loginlogs_lookup` (`username`,`ip`,`created_at`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `login_logs`
--

INSERT INTO `login_logs` VALUES
(1,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 09:47:26'),
(2,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 10:12:48'),
(3,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 10:12:55'),
(4,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 10:24:20'),
(5,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 10:42:19'),
(6,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 10:54:16'),
(7,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 10:54:24'),
(8,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:04:58'),
(9,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:42:33'),
(10,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:42:44'),
(11,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:43:52'),
(12,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:44:06'),
(13,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:52:19'),
(14,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:52:27'),
(15,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:53:16'),
(16,'Hans Engfeldt','192.168.1.207',1,'2026-07-30 11:53:23');

--
-- Table structure for table `notes`
--

CREATE TABLE `notes` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `title` varchar(255) NOT NULL DEFAULT '',
  `content` mediumtext DEFAULT NULL,
  `type` enum('text','checklist') NOT NULL DEFAULT 'text',
  `color` varchar(20) NOT NULL DEFAULT 'default',
  `pinned` tinyint(1) NOT NULL DEFAULT 0,
  `archived` tinyint(1) NOT NULL DEFAULT 0,
  `position` int(11) NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  `updated_at` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
  PRIMARY KEY (`id`),
  KEY `idx_notes_user_archived` (`user_id`,`archived`),
  CONSTRAINT `fk_notes_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `notes`
--

INSERT INTO `notes` VALUES
(1,1,'Test',NULL,'checklist','blue',0,0,0,'2026-07-30 09:42:09','2026-07-30 09:42:09'),
(2,1,'coop','abc123\ndea002\nweb80d','text','pink',0,0,0,'2026-07-30 10:10:25','2026-07-30 11:46:19');

--
-- Table structure for table `users`
--

CREATE TABLE `users` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `username` varchar(60) NOT NULL,
  `password_hash` varchar(255) NOT NULL,
  `totp_secret` varchar(32) DEFAULT NULL,
  `totp_enabled` tinyint(1) NOT NULL DEFAULT 0,
  `created_at` datetime NOT NULL DEFAULT current_timestamp(),
  PRIMARY KEY (`id`),
  UNIQUE KEY `username` (`username`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;

--
-- Dumping data for table `users`
--

INSERT INTO `users` VALUES
(1,'Hans Engfeldt','$2y$10$1JNsIrhaFm5wrmf8RhukLOgLTsuGp15Oz/JVatmYDV1svDPbeZ1jG','3CHP5CB7DM2GGN6N',1,'2026-07-30 09:36:17');


