@@ -13,6 +13,10 @@ const tables = {
1313 { name : 'last_name' , def : 'VARCHAR(255)' } ,
1414 { name : 'password_set' , def : 'TINYINT(1) NOT NULL DEFAULT 0' } ,
1515 { name : 'is_admin' , def : 'TINYINT(1) NOT NULL DEFAULT 0' } ,
16+ { name : 'restricted' , def : 'TINYINT(1) NOT NULL DEFAULT 0' } ,
17+ { name : 'auth_restricted' , def : 'TINYINT(1) NOT NULL DEFAULT 0' } ,
18+ { name : 'token_version' , def : 'INT NOT NULL DEFAULT 0' } ,
19+ { name : 'avatar' , def : 'VARCHAR(255) DEFAULT NULL' } ,
1620 { name : 'ptero_client_api_key' , def : 'VARCHAR(255) DEFAULT NULL' } ,
1721 { name : 'created_at' , def : 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP' } ,
1822 ] ,
@@ -47,6 +51,38 @@ const tables = {
4751 { name : 'created_at' , def : 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP' } ,
4852 ] ,
4953 } ,
54+ nests : {
55+ columns : [
56+ { name : 'id' , def : 'INT AUTO_INCREMENT PRIMARY KEY' } ,
57+ { name : 'ptero_nest_id' , def : 'INT NOT NULL UNIQUE' } ,
58+ { name : 'name' , def : 'VARCHAR(255) NOT NULL' } ,
59+ { name : 'created_at' , def : 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP' } ,
60+ ] ,
61+ } ,
62+ egg_resources : {
63+ columns : [
64+ { name : 'id' , def : 'INT AUTO_INCREMENT PRIMARY KEY' } ,
65+ { name : 'ptero_nest_id' , def : 'INT NOT NULL' } ,
66+ { name : 'ptero_egg_id' , def : 'INT NOT NULL' } ,
67+ { name : 'cpu_limit' , def : 'INT DEFAULT NULL' } ,
68+ { name : 'memory_limit' , def : 'INT DEFAULT NULL' } ,
69+ { name : 'disk_limit' , def : 'INT DEFAULT NULL' } ,
70+ { name : 'created_at' , def : 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP' } ,
71+ { name : 'updated_at' , def : 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP' } ,
72+ ] ,
73+ } ,
74+ notifications : {
75+ columns : [
76+ { name : 'id' , def : 'INT AUTO_INCREMENT PRIMARY KEY' } ,
77+ { name : 'user_id' , def : 'INT NOT NULL' } ,
78+ { name : 'title' , def : 'VARCHAR(255) NOT NULL' } ,
79+ { name : 'message' , def : 'TEXT NOT NULL' } ,
80+ { name : 'type' , def : "VARCHAR(20) NOT NULL DEFAULT 'info'" } ,
81+ { name : 'link' , def : 'VARCHAR(255) DEFAULT NULL' } ,
82+ { name : 'is_read' , def : 'TINYINT(1) NOT NULL DEFAULT 0' } ,
83+ { name : 'created_at' , def : 'TIMESTAMP DEFAULT CURRENT_TIMESTAMP' } ,
84+ ] ,
85+ } ,
5086
5187} ;
5288
@@ -67,6 +103,10 @@ const constraints = [
67103 { table : 'user_ips' , sql : 'ALTER TABLE user_ips ADD CONSTRAINT fk_user_ips_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE' , name : 'fk_user_ips_user' } ,
68104 { table : 'activity_log' , sql : 'ALTER TABLE activity_log ADD INDEX idx_activity_user (user_id)' , name : 'idx_activity_user' } ,
69105 { table : 'activity_log' , sql : 'ALTER TABLE activity_log ADD INDEX idx_activity_created (created_at)' , name : 'idx_activity_created' } ,
106+ { table : 'egg_resources' , sql : 'ALTER TABLE egg_resources ADD UNIQUE INDEX idx_egg_resources_nest_egg (ptero_nest_id, ptero_egg_id)' , name : 'idx_egg_resources_nest_egg' } ,
107+ { table : 'notifications' , sql : 'ALTER TABLE notifications ADD INDEX idx_notif_user (user_id)' , name : 'idx_notif_user' } ,
108+ { table : 'notifications' , sql : 'ALTER TABLE notifications ADD INDEX idx_notif_user_read (user_id, is_read)' , name : 'idx_notif_user_read' } ,
109+ { table : 'notifications' , sql : 'ALTER TABLE notifications ADD CONSTRAINT fk_notif_user FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE' , name : 'fk_notif_user' } ,
70110] ;
71111
72112export async function migrate ( ) {
0 commit comments