mirror of
https://github.com/HeyPuter/puter.git
synced 2025-01-23 22:40:20 +08:00
fix: group permission audit table
This commit is contained in:
parent
4af279a72f
commit
7d2f6d256f
@ -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 = 16;
|
const TARGET_VERSION = 17;
|
||||||
|
|
||||||
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}`);
|
||||||
@ -65,6 +65,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
|
|||||||
'0016_group-permissions.sql',
|
'0016_group-permissions.sql',
|
||||||
'0017_publicdirs.sql',
|
'0017_publicdirs.sql',
|
||||||
'0018_fix-0003.sql',
|
'0018_fix-0003.sql',
|
||||||
|
'0019_fix-0016.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 ) {
|
||||||
@ -145,6 +146,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
|
|||||||
upgrade_files.push('0018_fix-0003.sql');
|
upgrade_files.push('0018_fix-0003.sql');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( user_version <= 16 ) {
|
||||||
|
upgrade_files.push('0019_fix-0016.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,41 @@
|
|||||||
|
CREATE TABLE `audit_user_to_group_permissions_new` (
|
||||||
|
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
|
||||||
|
"user_id" INTEGER DEFAULT NULL,
|
||||||
|
"user_id_keep" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
"group_id" INTEGER DEFAULT NULL,
|
||||||
|
"group_id_keep" INTEGER NOT NULL,
|
||||||
|
|
||||||
|
"permission" TEXT NOT NULL,
|
||||||
|
"extra" JSON DEFAULT NULL,
|
||||||
|
|
||||||
|
"action" TEXT DEFAULT NULL,
|
||||||
|
"reason" TEXT DEFAULT NULL,
|
||||||
|
|
||||||
|
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
|
||||||
|
FOREIGN KEY("user_id") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
|
||||||
|
FOREIGN KEY("group_id") REFERENCES "group" ("id") ON DELETE SET NULL ON UPDATE CASCADE
|
||||||
|
);
|
||||||
|
|
||||||
|
INSERT INTO `audit_user_to_group_permissions_new`
|
||||||
|
(
|
||||||
|
`id`,
|
||||||
|
`user_id`, `user_id_keep`,
|
||||||
|
`group_id`, `group_id_keep`,
|
||||||
|
`permission`, `extra`, `action`, `reason`,
|
||||||
|
`created_at`
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
`id`,
|
||||||
|
`user_id`, `user_id_keep`,
|
||||||
|
`group_id`, `group_id_keep`,
|
||||||
|
`permission`, `extra`, `action`, `reason`,
|
||||||
|
`created_at`
|
||||||
|
FROM `audit_user_to_group_permissions`;
|
||||||
|
DROP TABLE `audit_user_to_group_permissions`;
|
||||||
|
|
||||||
|
ALTER TABLE `audit_user_to_group_permissions_new`
|
||||||
|
RENAME TO `audit_user_to_group_permissions`;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user