@axium/storage 0.3.5 → 0.3.6
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.
- package/dist/plugin.js +8 -6
- package/package.json +1 -1
package/dist/plugin.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { formatBytes } from '@axium/core/format';
|
|
2
|
+
import * as acl from '@axium/server/acl';
|
|
2
3
|
import config from '@axium/server/config';
|
|
3
|
-
import { count, database, warnExists } from '@axium/server/database';
|
|
4
|
+
import { count, createIndex, database, warnExists } from '@axium/server/database';
|
|
4
5
|
import { done, start } from '@axium/server/io';
|
|
5
6
|
import { sql } from 'kysely';
|
|
6
7
|
import pkg from '../package.json' with { type: 'json' };
|
|
@@ -20,7 +21,7 @@ async function db_init(opt) {
|
|
|
20
21
|
.createTable('storage')
|
|
21
22
|
.addColumn('id', 'uuid', col => col.primaryKey().defaultTo(sql `gen_random_uuid()`))
|
|
22
23
|
.addColumn('userId', 'uuid', col => col.notNull().references('users.id').onDelete('cascade').onUpdate('cascade'))
|
|
23
|
-
.addColumn('parentId', 'uuid', col => col.references('storage.
|
|
24
|
+
.addColumn('parentId', 'uuid', col => col.references('storage.id').onDelete('cascade').onUpdate('cascade').defaultTo(null))
|
|
24
25
|
.addColumn('createdAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
25
26
|
.addColumn('modifiedAt', 'timestamptz', col => col.notNull().defaultTo(sql `now()`))
|
|
26
27
|
.addColumn('size', 'integer', col => col.notNull())
|
|
@@ -34,19 +35,20 @@ async function db_init(opt) {
|
|
|
34
35
|
.execute()
|
|
35
36
|
.then(done)
|
|
36
37
|
.catch(warnExists);
|
|
37
|
-
|
|
38
|
-
await
|
|
39
|
-
|
|
40
|
-
await database.schema.createIndex('storage_parentId_index').on('storage').column('parentId').execute().then(done).catch(warnExists);
|
|
38
|
+
await createIndex('storage', 'userId');
|
|
39
|
+
await createIndex('storage', 'parentId');
|
|
40
|
+
await acl.createTable('storage');
|
|
41
41
|
}
|
|
42
42
|
async function db_wipe(opt) {
|
|
43
43
|
start('Removing data from user storage');
|
|
44
44
|
await database.deleteFrom('storage').execute();
|
|
45
|
+
await acl.wipeTable('storage');
|
|
45
46
|
done();
|
|
46
47
|
}
|
|
47
48
|
async function remove(opt) {
|
|
48
49
|
start('Dropping table storage');
|
|
49
50
|
await database.schema.dropTable('storage').execute();
|
|
51
|
+
await acl.dropTable('storage');
|
|
50
52
|
done();
|
|
51
53
|
}
|
|
52
54
|
async function clean(opt) {
|