pica/database/migrations/m0.sql

37 lines
988 B
MySQL
Raw Normal View History

2023-12-11 23:29:55 +00:00
--creating system table
2023-12-08 22:26:16 +00:00
CREATE TABLE IF NOT EXISTS system (
`key` VARCHAR(32) PRIMARY KEY,
`value` TEXT
);
2023-12-11 23:29:55 +00:00
--creating roles table
CREATE TABLE IF NOT EXISTS roles (
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`name` VARCHAR(256) UNIQUE NOT NULL,
`color` INTEGER UNSIGNED DEFAULT 0
);
--creating accounts table
CREATE TABLE IF NOT EXISTS accounts (
`id` INTEGER UNSIGNED AUTO_INCREMENT PRIMARY KEY,
`login` VARCHAR(256) UNIQUE NOT NULL,
`nick` VARCHAR(256),
`type` INTEGER UNSIGNED NOT NULL,
`password` VARCHAR(64),
`salt` VARCHAR(32),
`role` INTEGER UNSIGNED NOT NULL,
`created` TIMESTAMP DEFAULT UTC_TIMESTAMP(),
FOREIGN KEY (role) REFERENCES roles(id)
);
--creating defailt roles
INSERT IGNORE INTO roles (`name`)
VALUES ('root');
--inserting initial version
2023-12-08 22:26:16 +00:00
INSERT INTO system (`key`, `value`) VALUES ('version', '0');
2023-12-11 23:29:55 +00:00
--recording initial time
INSERT INTO system (`key`, `value`) VALUES ('created', UTC_TIMESTAMP());