2021-12-12 16:49:46 +03:00
|
|
|
DROP TABLE IF EXISTS `memos`;
|
2021-12-12 07:14:40 +03:00
|
|
|
DROP TABLE IF EXISTS `queries`;
|
2021-12-14 15:08:12 +03:00
|
|
|
DROP TABLE IF EXISTS `resources`;
|
2021-12-12 16:49:46 +03:00
|
|
|
DROP TABLE IF EXISTS `users`;
|
|
|
|
|
|
|
|
CREATE TABLE `users` (
|
2021-12-14 05:36:52 +03:00
|
|
|
`id` TEXT NOT NULL PRIMARY KEY,
|
|
|
|
`username` TEXT NOT NULL,
|
|
|
|
`password` TEXT NOT NULL,
|
2021-12-14 15:40:24 +03:00
|
|
|
`open_id` TEXT NOT NULL DEFAULT '',
|
2021-12-14 05:36:52 +03:00
|
|
|
`created_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
2021-12-12 16:49:46 +03:00
|
|
|
`updated_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
2022-01-09 06:44:12 +03:00
|
|
|
UNIQUE(`username`, `open_id`)
|
2021-12-12 16:49:46 +03:00
|
|
|
);
|
|
|
|
|
2021-12-12 07:14:40 +03:00
|
|
|
CREATE TABLE `queries` (
|
|
|
|
`id` TEXT NOT NULL PRIMARY KEY,
|
|
|
|
`user_id` TEXT NOT NULL,
|
|
|
|
`title` TEXT NOT NULL,
|
|
|
|
`querystring` TEXT NOT NULL,
|
2021-12-12 16:49:46 +03:00
|
|
|
`created_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
|
|
|
`updated_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
|
|
|
`pinned_at` TEXT NOT NULL DEFAULT '',
|
2021-12-12 07:14:40 +03:00
|
|
|
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`)
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE `memos` (
|
|
|
|
`id` TEXT NOT NULL PRIMARY KEY,
|
|
|
|
`content` TEXT NOT NULL,
|
|
|
|
`user_id` TEXT NOT NULL,
|
2021-12-12 16:49:46 +03:00
|
|
|
`created_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
|
|
|
`updated_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
|
|
|
`deleted_at` TEXT NOT NULL DEFAULT '',
|
2021-12-12 07:14:40 +03:00
|
|
|
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`)
|
|
|
|
);
|
|
|
|
|
2021-12-14 15:08:12 +03:00
|
|
|
CREATE TABLE `resources` (
|
|
|
|
`id` TEXT NOT NULL PRIMARY KEY,
|
|
|
|
`user_id` TEXT NOT NULL,
|
|
|
|
`filename` TEXT NOT NULL,
|
|
|
|
`blob` BLOB NOT NULL,
|
|
|
|
`type` TEXT NOT NULL,
|
|
|
|
`size` INTEGER NOT NULL DEFAULT 0,
|
|
|
|
`created_at` TEXT NOT NULL DEFAULT (DATETIME('now', 'localtime')),
|
|
|
|
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`)
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2021-12-10 08:41:17 +03:00
|
|
|
INSERT INTO `users`
|
2022-01-09 06:44:12 +03:00
|
|
|
(`id`, `username`, `password`, `open_id`)
|
2021-12-10 08:41:17 +03:00
|
|
|
VALUES
|
2022-01-09 06:44:12 +03:00
|
|
|
('1', 'guest', '123456', 'guest_open_id'),
|
|
|
|
('2', 'mine', '123456', 'mine_open_id');
|
2021-12-10 08:41:17 +03:00
|
|
|
|
|
|
|
INSERT INTO `memos`
|
2021-12-12 07:14:40 +03:00
|
|
|
(`id`, `content`, `user_id`)
|
2021-12-10 08:41:17 +03:00
|
|
|
VALUES
|
2021-12-12 16:49:46 +03:00
|
|
|
('1', '👋 Welcome to memos', '1'),
|
|
|
|
('2', '👋 Welcome to memos', '2');
|