adminizer 4.4.0-build.162 → 4.4.0-build.164
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -4,6 +4,34 @@
|
|
|
4
4
|
* notificationap, usernotificationap, navigationap, groupapuserap
|
|
5
5
|
*/
|
|
6
6
|
export async function up(knex) {
|
|
7
|
+
// Helper to get the correct default timestamp based on database client
|
|
8
|
+
const getDefaultTimestamp = () => {
|
|
9
|
+
const client = knex.client.config.client;
|
|
10
|
+
if (client === 'pg' || client === 'postgresql') {
|
|
11
|
+
return knex.raw('CURRENT_TIMESTAMP');
|
|
12
|
+
}
|
|
13
|
+
else if (client === 'sqlite3') {
|
|
14
|
+
return knex.raw("(datetime('now'))");
|
|
15
|
+
}
|
|
16
|
+
else if (client === 'mysql' || client === 'mysql2') {
|
|
17
|
+
return knex.raw('CURRENT_TIMESTAMP');
|
|
18
|
+
}
|
|
19
|
+
return knex.fn.now();
|
|
20
|
+
};
|
|
21
|
+
// Helper to get UUID default based on database client
|
|
22
|
+
const getUuidDefault = () => {
|
|
23
|
+
const client = knex.client.config.client;
|
|
24
|
+
if (client === 'pg' || client === 'postgresql') {
|
|
25
|
+
return knex.raw('gen_random_uuid()');
|
|
26
|
+
}
|
|
27
|
+
else if (client === 'sqlite3') {
|
|
28
|
+
// SQLite doesn't have native UUID, will need to handle in application
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
return knex.raw('UUID()');
|
|
32
|
+
};
|
|
33
|
+
const defaultTimestamp = getDefaultTimestamp();
|
|
34
|
+
const uuidDefault = getUuidDefault();
|
|
7
35
|
// userap
|
|
8
36
|
await knex.schema.createTable("userap", (table) => {
|
|
9
37
|
table.increments("id").primary().notNullable();
|
|
@@ -20,8 +48,8 @@ export async function up(knex) {
|
|
|
20
48
|
table.boolean("isAdministrator");
|
|
21
49
|
table.json("widgets");
|
|
22
50
|
table.boolean("isConfirmed");
|
|
23
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
24
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
51
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
52
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
25
53
|
});
|
|
26
54
|
// groupap
|
|
27
55
|
await knex.schema.createTable("groupap", (table) => {
|
|
@@ -29,13 +57,18 @@ export async function up(knex) {
|
|
|
29
57
|
table.string("name").unique();
|
|
30
58
|
table.string("description");
|
|
31
59
|
table.json("tokens");
|
|
32
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
33
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
60
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
61
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
34
62
|
});
|
|
35
63
|
// mediamanagerap (self-ref via parentId)
|
|
36
64
|
await knex.schema.createTable("mediamanagerap", (table) => {
|
|
37
|
-
|
|
38
|
-
|
|
65
|
+
if (uuidDefault) {
|
|
66
|
+
table.uuid("id").primary().notNullable().defaultTo(uuidDefault);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
table.uuid("id").primary().notNullable();
|
|
70
|
+
}
|
|
71
|
+
table.uuid("parentId").nullable().references("id").inTable("mediamanagerap");
|
|
39
72
|
table.string("mimeType");
|
|
40
73
|
table.string("path");
|
|
41
74
|
table.integer("size");
|
|
@@ -43,30 +76,40 @@ export async function up(knex) {
|
|
|
43
76
|
table.string("tag");
|
|
44
77
|
table.string("url");
|
|
45
78
|
table.string("filename");
|
|
46
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
47
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
79
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
80
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
48
81
|
});
|
|
49
82
|
// mediamanagermetaap (belongsTo mediamanagerap via parentId)
|
|
50
83
|
await knex.schema.createTable("mediamanagermetaap", (table) => {
|
|
51
|
-
|
|
84
|
+
if (uuidDefault) {
|
|
85
|
+
table.uuid("id").primary().notNullable().defaultTo(uuidDefault);
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
table.uuid("id").primary().notNullable();
|
|
89
|
+
}
|
|
52
90
|
table.string("key");
|
|
53
91
|
table.json("value");
|
|
54
92
|
table.boolean("isPublic");
|
|
55
|
-
table.uuid("parentId").nullable().references("id").inTable("mediamanagerap")
|
|
56
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
57
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
93
|
+
table.uuid("parentId").nullable().references("id").inTable("mediamanagerap");
|
|
94
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
95
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
58
96
|
});
|
|
59
97
|
// mediamanagerassociationsap (belongsTo mediamanagerap via fileId)
|
|
60
98
|
await knex.schema.createTable("mediamanagerassociationsap", (table) => {
|
|
61
|
-
|
|
99
|
+
if (uuidDefault) {
|
|
100
|
+
table.uuid("id").primary().notNullable().defaultTo(uuidDefault);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
table.uuid("id").primary().notNullable();
|
|
104
|
+
}
|
|
62
105
|
table.string("mediaManagerId");
|
|
63
106
|
table.json("model");
|
|
64
107
|
table.json("modelId");
|
|
65
108
|
table.string("widgetName");
|
|
66
109
|
table.integer("sortOrder");
|
|
67
|
-
table.uuid("fileId").nullable().references("id").inTable("mediamanagerap")
|
|
68
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
69
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
110
|
+
table.uuid("fileId").nullable().references("id").inTable("mediamanagerap");
|
|
111
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
112
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
70
113
|
});
|
|
71
114
|
// notificationap
|
|
72
115
|
await knex.schema.createTable("notificationap", (table) => {
|
|
@@ -76,32 +119,32 @@ export async function up(knex) {
|
|
|
76
119
|
table.string("notificationClass");
|
|
77
120
|
table.string("channel");
|
|
78
121
|
table.json("metadata");
|
|
79
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
80
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
122
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
123
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
81
124
|
});
|
|
82
125
|
// usernotificationap (FK to notificationap via column notificationIdId)
|
|
83
126
|
await knex.schema.createTable("usernotificationap", (table) => {
|
|
84
127
|
table.increments("id").primary().notNullable();
|
|
85
128
|
table.integer("userId");
|
|
86
|
-
table.integer("notificationIdId").nullable().references("id").inTable("notificationap")
|
|
129
|
+
table.integer("notificationIdId").nullable().references("id").inTable("notificationap");
|
|
87
130
|
table.boolean("read");
|
|
88
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
89
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
131
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
132
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
90
133
|
});
|
|
91
134
|
// navigationap
|
|
92
135
|
await knex.schema.createTable("navigationap", (table) => {
|
|
93
136
|
table.increments("id").primary().notNullable();
|
|
94
137
|
table.string("label").unique();
|
|
95
138
|
table.json("tree");
|
|
96
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
97
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
139
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
140
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
98
141
|
});
|
|
99
142
|
// M:N join: GroupAP <-> UserAP via "groupapuserap"
|
|
100
143
|
await knex.schema.createTable("groupapuserap", (table) => {
|
|
101
|
-
table.integer("UserAPId").notNullable().references("id").inTable("userap")
|
|
102
|
-
table.integer("GroupAPId").notNullable().references("id").inTable("groupap")
|
|
103
|
-
table.timestamp("createdAt").notNullable().defaultTo(
|
|
104
|
-
table.timestamp("updatedAt").notNullable().defaultTo(
|
|
144
|
+
table.integer("UserAPId").notNullable().references("id").inTable("userap");
|
|
145
|
+
table.integer("GroupAPId").notNullable().references("id").inTable("groupap");
|
|
146
|
+
table.timestamp("createdAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
147
|
+
table.timestamp("updatedAt", { useTz: false }).notNullable().defaultTo(defaultTimestamp);
|
|
105
148
|
table.primary(["UserAPId", "GroupAPId"]);
|
|
106
149
|
});
|
|
107
150
|
}
|