adminizer 4.4.0-build.161 → 4.4.0-build.162
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.
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Knex } from "knex";
|
|
2
|
+
/**
|
|
3
|
+
* Creates all system model tables for Adminizer
|
|
4
|
+
* Tables: userap, groupap, mediamanagerap, mediamanagermetaap, mediamanagerassociationsap,
|
|
5
|
+
* notificationap, usernotificationap, navigationap, groupapuserap
|
|
6
|
+
*/
|
|
7
|
+
export declare function up(knex: Knex): Promise<void>;
|
|
8
|
+
export declare function down(knex: Knex): Promise<void>;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates all system model tables for Adminizer
|
|
3
|
+
* Tables: userap, groupap, mediamanagerap, mediamanagermetaap, mediamanagerassociationsap,
|
|
4
|
+
* notificationap, usernotificationap, navigationap, groupapuserap
|
|
5
|
+
*/
|
|
6
|
+
export async function up(knex) {
|
|
7
|
+
// userap
|
|
8
|
+
await knex.schema.createTable("userap", (table) => {
|
|
9
|
+
table.increments("id").primary().notNullable();
|
|
10
|
+
table.string("login").unique();
|
|
11
|
+
table.string("fullName");
|
|
12
|
+
table.string("email");
|
|
13
|
+
table.string("avatar");
|
|
14
|
+
table.string("passwordHashed");
|
|
15
|
+
table.string("timezone");
|
|
16
|
+
table.string("expires");
|
|
17
|
+
table.string("locale");
|
|
18
|
+
table.boolean("isDeleted");
|
|
19
|
+
table.boolean("isActive");
|
|
20
|
+
table.boolean("isAdministrator");
|
|
21
|
+
table.json("widgets");
|
|
22
|
+
table.boolean("isConfirmed");
|
|
23
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
24
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
25
|
+
});
|
|
26
|
+
// groupap
|
|
27
|
+
await knex.schema.createTable("groupap", (table) => {
|
|
28
|
+
table.increments("id").primary().notNullable();
|
|
29
|
+
table.string("name").unique();
|
|
30
|
+
table.string("description");
|
|
31
|
+
table.json("tokens");
|
|
32
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
33
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
34
|
+
});
|
|
35
|
+
// mediamanagerap (self-ref via parentId)
|
|
36
|
+
await knex.schema.createTable("mediamanagerap", (table) => {
|
|
37
|
+
table.uuid("id").primary().notNullable().defaultTo(knex.raw("gen_random_uuid()"));
|
|
38
|
+
table.uuid("parentId").nullable().references("id").inTable("mediamanagerap").onDelete("SET NULL");
|
|
39
|
+
table.string("mimeType");
|
|
40
|
+
table.string("path");
|
|
41
|
+
table.integer("size");
|
|
42
|
+
table.string("group");
|
|
43
|
+
table.string("tag");
|
|
44
|
+
table.string("url");
|
|
45
|
+
table.string("filename");
|
|
46
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
47
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
48
|
+
});
|
|
49
|
+
// mediamanagermetaap (belongsTo mediamanagerap via parentId)
|
|
50
|
+
await knex.schema.createTable("mediamanagermetaap", (table) => {
|
|
51
|
+
table.uuid("id").primary().notNullable().defaultTo(knex.raw("gen_random_uuid()"));
|
|
52
|
+
table.string("key");
|
|
53
|
+
table.json("value");
|
|
54
|
+
table.boolean("isPublic");
|
|
55
|
+
table.uuid("parentId").nullable().references("id").inTable("mediamanagerap").onDelete("SET NULL");
|
|
56
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
57
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
58
|
+
});
|
|
59
|
+
// mediamanagerassociationsap (belongsTo mediamanagerap via fileId)
|
|
60
|
+
await knex.schema.createTable("mediamanagerassociationsap", (table) => {
|
|
61
|
+
table.uuid("id").primary().notNullable().defaultTo(knex.raw("gen_random_uuid()"));
|
|
62
|
+
table.string("mediaManagerId");
|
|
63
|
+
table.json("model");
|
|
64
|
+
table.json("modelId");
|
|
65
|
+
table.string("widgetName");
|
|
66
|
+
table.integer("sortOrder");
|
|
67
|
+
table.uuid("fileId").nullable().references("id").inTable("mediamanagerap").onDelete("SET NULL");
|
|
68
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
69
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
70
|
+
});
|
|
71
|
+
// notificationap
|
|
72
|
+
await knex.schema.createTable("notificationap", (table) => {
|
|
73
|
+
table.increments("id").primary().notNullable();
|
|
74
|
+
table.string("title");
|
|
75
|
+
table.string("message");
|
|
76
|
+
table.string("notificationClass");
|
|
77
|
+
table.string("channel");
|
|
78
|
+
table.json("metadata");
|
|
79
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
80
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
81
|
+
});
|
|
82
|
+
// usernotificationap (FK to notificationap via column notificationIdId)
|
|
83
|
+
await knex.schema.createTable("usernotificationap", (table) => {
|
|
84
|
+
table.increments("id").primary().notNullable();
|
|
85
|
+
table.integer("userId");
|
|
86
|
+
table.integer("notificationIdId").nullable().references("id").inTable("notificationap").onDelete("SET NULL");
|
|
87
|
+
table.boolean("read");
|
|
88
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
89
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
90
|
+
});
|
|
91
|
+
// navigationap
|
|
92
|
+
await knex.schema.createTable("navigationap", (table) => {
|
|
93
|
+
table.increments("id").primary().notNullable();
|
|
94
|
+
table.string("label").unique();
|
|
95
|
+
table.json("tree");
|
|
96
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
97
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
98
|
+
});
|
|
99
|
+
// M:N join: GroupAP <-> UserAP via "groupapuserap"
|
|
100
|
+
await knex.schema.createTable("groupapuserap", (table) => {
|
|
101
|
+
table.integer("UserAPId").notNullable().references("id").inTable("userap").onDelete("CASCADE");
|
|
102
|
+
table.integer("GroupAPId").notNullable().references("id").inTable("groupap").onDelete("CASCADE");
|
|
103
|
+
table.timestamp("createdAt").notNullable().defaultTo(knex.fn.now());
|
|
104
|
+
table.timestamp("updatedAt").notNullable().defaultTo(knex.fn.now());
|
|
105
|
+
table.primary(["UserAPId", "GroupAPId"]);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
export async function down(knex) {
|
|
109
|
+
await knex.schema.dropTableIfExists("groupapuserap");
|
|
110
|
+
await knex.schema.dropTableIfExists("usernotificationap");
|
|
111
|
+
await knex.schema.dropTableIfExists("mediamanagermetaap");
|
|
112
|
+
await knex.schema.dropTableIfExists("mediamanagerassociationsap");
|
|
113
|
+
await knex.schema.dropTableIfExists("mediamanagerap");
|
|
114
|
+
await knex.schema.dropTableIfExists("navigationap");
|
|
115
|
+
await knex.schema.dropTableIfExists("notificationap");
|
|
116
|
+
await knex.schema.dropTableIfExists("groupap");
|
|
117
|
+
await knex.schema.dropTableIfExists("userap");
|
|
118
|
+
}
|