memos/resources/initial_db.sql

49 lines
1.3 KiB
MySQL
Raw Normal View History

2021-12-09 22:02:57 +08:00
/*
2021-12-10 13:41:17 +08:00
* Re-create tables and insert initial data
2021-12-09 22:02:57 +08:00
*/
2021-12-10 13:41:17 +08:00
DROP TABLE IF EXISTS `users`;
2021-12-08 23:43:14 +08:00
CREATE TABLE `users` (
`id` TEXT NOT NULL PRIMARY KEY,
`username` TEXT NOT NULL,
`password` TEXT NOT NULL,
2021-12-10 13:41:17 +08:00
`github_name` TEXT DEFAULT '',
`wx_open_id` TEXT DEFAULT '',
2021-12-08 23:43:14 +08:00
`created_at` TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
);
2021-12-10 13:41:17 +08:00
INSERT INTO `users`
(`id`, `username`, `password`)
VALUES
('0', 'admin', '123456'),
('1', 'guest', '123456');
DROP TABLE IF EXISTS `memos`;
2021-12-08 23:43:14 +08:00
CREATE TABLE `memos` (
`id` TEXT NOT NULL PRIMARY KEY,
`content` TEXT NOT NULL,
`user_id` TEXT NOT NULL,
`created_at` TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
2021-12-10 13:41:17 +08:00
`deleted_at` TEXT DEFAULT '',
2021-12-08 23:43:14 +08:00
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`)
);
2021-12-10 13:41:17 +08:00
INSERT INTO `memos`
(`id`, `content`, `user_id`, )
VALUES
('0', '👋 Welcome to memos', '0'),
('1', '👋 Welcome to memos', '1');
DROP TABLE IF EXISTS `queries`;
2021-12-08 23:43:14 +08:00
CREATE TABLE `queries` (
`id` TEXT NOT NULL PRIMARY KEY,
`user_id` TEXT NOT NULL,
`title` TEXT NOT NULL,
`querystring` TEXT NOT NULL,
`created_at` TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
2021-12-10 13:41:17 +08:00
`pinned_at` TEXT DEFAULT '',
2021-12-08 23:43:14 +08:00
FOREIGN KEY(`user_id`) REFERENCES `users`(`id`)
);