Skip to content

Commit 1429d6f

Browse files
committed
fix: column nullability blunder
1 parent b10302a commit 1429d6f

File tree

2 files changed

+46
-1
lines changed

2 files changed

+46
-1
lines changed

packages/backend/src/services/database/SqliteDatabaseAccessService.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
4242
this.db = new Database(this.config.path);
4343

4444
// Database upgrade logic
45-
const TARGET_VERSION = 15;
45+
const TARGET_VERSION = 16;
4646

4747
if ( do_setup ) {
4848
this.log.noticeme(`SETUP: creating database at ${this.config.path}`);
@@ -64,6 +64,7 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
6464
'0015_group.sql',
6565
'0016_group-permissions.sql',
6666
'0017_publicdirs.sql',
67+
'0018_fix-0003.sql',
6768
].map(p => path_.join(__dirname, 'sqlite_setup', p));
6869
const fs = require('fs');
6970
for ( const filename of sql_files ) {
@@ -140,6 +141,10 @@ class SqliteDatabaseAccessService extends BaseDatabaseAccessService {
140141
upgrade_files.push('0017_publicdirs.sql');
141142
}
142143

144+
if ( user_version <= 15 ) {
145+
upgrade_files.push('0018_fix-0003.sql');
146+
}
147+
143148
if ( upgrade_files.length > 0 ) {
144149
this.log.noticeme(`Database out of date: ${this.config.path}`);
145150
this.log.noticeme(`UPGRADING DATABASE: ${user_version} -> ${TARGET_VERSION}`);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
CREATE TABLE `audit_user_to_user_permissions_new` (
2+
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
3+
4+
"issuer_user_id" INTEGER DEFAULT NULL,
5+
"issuer_user_id_keep" INTEGER DEFAULT NULL,
6+
7+
"holder_user_id" INTEGER DEFAULT NULL,
8+
"holder_user_id_keep" INTEGER DEFAULT NULL,
9+
10+
"permission" TEXT NOT NULL,
11+
"extra" JSON DEFAULT NULL,
12+
13+
"action" TEXT DEFAULT NULL,
14+
"reason" TEXT DEFAULT NULL,
15+
16+
"created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
17+
18+
FOREIGN KEY("issuer_user_id") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE,
19+
FOREIGN KEY("holder_user_id") REFERENCES "user" ("id") ON DELETE SET NULL ON UPDATE CASCADE
20+
);
21+
22+
INSERT INTO `audit_user_to_user_permissions_new`
23+
(
24+
`id`,
25+
`issuer_user_id`, `issuer_user_id_keep`,
26+
`holder_user_id`, `holder_user_id_keep`,
27+
`permission`, `extra`, `action`, `reason`,
28+
`created_at`
29+
)
30+
SELECT
31+
`id`,
32+
`issuer_user_id`, `issuer_user_id_keep`,
33+
`holder_user_id`, `holder_user_id_keep`,
34+
`permission`, `extra`, `action`, `reason`,
35+
`created_at`
36+
FROM `audit_user_to_user_permissions`;
37+
DROP TABLE `audit_user_to_user_permissions`;
38+
39+
ALTER TABLE `audit_user_to_user_permissions_new`
40+
RENAME TO `audit_user_to_user_permissions`;

0 commit comments

Comments
 (0)