mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
sql: group table
This commit is contained in:
parent
e132a203d1
commit
0ddb13e8ee
@ -42,7 +42,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
|
|||||||
this.db = new Database(this.config.path);
|
this.db = new Database(this.config.path);
|
||||||
|
|
||||||
// Database upgrade logic
|
// Database upgrade logic
|
||||||
const TARGET_VERSION = 12;
|
const TARGET_VERSION = 13;
|
||||||
|
|
||||||
if ( do_setup ) {
|
if ( do_setup ) {
|
||||||
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
|
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
|
||||||
@ -61,6 +61,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
|
|||||||
'0012_appmetadata.sql',
|
'0012_appmetadata.sql',
|
||||||
'0013_protected-apps.sql',
|
'0013_protected-apps.sql',
|
||||||
'0014_share.sql',
|
'0014_share.sql',
|
||||||
|
'0015_group.sql',
|
||||||
].map(p => path_.join(__dirname, 'sqlite_setup', p));
|
].map(p => path_.join(__dirname, 'sqlite_setup', p));
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
for ( const filename of sql_files ) {
|
for ( const filename of sql_files ) {
|
||||||
@ -125,6 +126,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
|
|||||||
upgrade_files.push('0014_share.sql');
|
upgrade_files.push('0014_share.sql');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( user_version <= 12 ) {
|
||||||
|
upgrade_files.push('0015_group.sql');
|
||||||
|
}
|
||||||
|
|
||||||
if ( upgrade_files.length > 0 ) {
|
if ( upgrade_files.length > 0 ) {
|
||||||
this.log.noticeme(`Database out of date: ${this.config.path}`);
|
this.log.noticeme(`Database out of date: ${this.config.path}`);
|
||||||
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);
|
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
CREATE TABLE `group` (
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"uid" TEXT NOT NULL UNIQUE,
|
||||||
|
"owner_user_id" INTEGER NOT NULL,
|
||||||
|
"extra" JSON DEFAULT NULL,
|
||||||
|
"metadata" JSON DEFAULT NULL,
|
||||||
|
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
|
|
||||||
|
CREATE TABLE `jct_user_group` (
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
"user_id" INTEGER NOT NULL,
|
||||||
|
"group_id" INTEGER NOT NULL,
|
||||||
|
"extra" JSON DEFAULT NULL,
|
||||||
|
"metadata" JSON DEFAULT NULL,
|
||||||
|
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
FOREIGN KEY("user_id") REFERENCES "user" ("id") ON DELETE CASCADE ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY("group_id") REFERENCES "group" ("id") ON DELETE CASCADE ON UPDATE CASCADE
|
||||||
|
);
|
Loading…
Reference in New Issue
Block a user