@dimah-s3/db 1.7.0 → 2.0.0-beta.0
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/README.md +62 -17
- package/dist/adapters/drizzle.d.ts +7 -0
- package/dist/adapters/drizzle.d.ts.map +1 -0
- package/dist/adapters/drizzle.js +3 -0
- package/dist/adapters/drizzle.js.map +1 -0
- package/dist/adapters/kysely.d.ts +7 -0
- package/dist/adapters/kysely.d.ts.map +1 -0
- package/dist/adapters/kysely.js +3 -0
- package/dist/adapters/kysely.js.map +1 -0
- package/dist/adapters/prisma.d.ts +7 -0
- package/dist/adapters/prisma.d.ts.map +1 -0
- package/dist/adapters/prisma.js +3 -0
- package/dist/adapters/prisma.js.map +1 -0
- package/dist/cli.d.ts +33 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +192 -4
- package/dist/cli.js.map +1 -1
- package/dist/client/db-client.d.ts +9 -85
- package/dist/client/db-client.d.ts.map +1 -1
- package/dist/client/db-object-source.d.ts +25 -0
- package/dist/client/db-object-source.d.ts.map +1 -0
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +96 -42
- package/dist/client/index.js.map +1 -1
- package/dist/drizzle/mysql.d.ts +1024 -0
- package/dist/drizzle/mysql.d.ts.map +1 -0
- package/dist/drizzle/mysql.js +123 -0
- package/dist/drizzle/mysql.js.map +1 -0
- package/dist/drizzle/pg.d.ts +963 -0
- package/dist/drizzle/pg.d.ts.map +1 -0
- package/dist/drizzle/pg.js +104 -0
- package/dist/drizzle/pg.js.map +1 -0
- package/dist/drizzle/shared.d.ts +16 -0
- package/dist/drizzle/shared.d.ts.map +1 -0
- package/dist/drizzle/sqlite.d.ts +1023 -0
- package/dist/drizzle/sqlite.d.ts.map +1 -0
- package/dist/drizzle/sqlite.js +107 -0
- package/dist/drizzle/sqlite.js.map +1 -0
- package/dist/folder-path.d.ts +32 -0
- package/dist/folder-path.d.ts.map +1 -0
- package/dist/fuma-db.d.ts +47 -5
- package/dist/fuma-db.d.ts.map +1 -1
- package/dist/index.d.ts +9 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1452 -620
- package/dist/index.js.map +1 -1
- package/dist/plugin/create-database-endpoints.d.ts +105 -21
- package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
- package/dist/plugin/create-database-lifecycle-hooks.d.ts +37 -19
- package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
- package/dist/plugin/db.d.ts +29 -118
- package/dist/plugin/db.d.ts.map +1 -1
- package/dist/plugin/object-access.d.ts +46 -0
- package/dist/plugin/object-access.d.ts.map +1 -0
- package/dist/plugin/public-stores.d.ts +33 -0
- package/dist/plugin/public-stores.d.ts.map +1 -0
- package/dist/plugin/purge.d.ts +49 -0
- package/dist/plugin/purge.d.ts.map +1 -0
- package/dist/plugin/quota.d.ts +25 -0
- package/dist/plugin/quota.d.ts.map +1 -0
- package/dist/plugin/schemas.d.ts +69 -0
- package/dist/plugin/schemas.d.ts.map +1 -0
- package/dist/plugin/scope.d.ts +31 -0
- package/dist/plugin/scope.d.ts.map +1 -0
- package/dist/plugin/to-db-client-object.d.ts +8 -4
- package/dist/plugin/to-db-client-object.d.ts.map +1 -1
- package/dist/schema/v1.d.ts +1 -8
- package/dist/schema/v1.d.ts.map +1 -1
- package/dist/schema/v2.d.ts +64 -0
- package/dist/schema/v2.d.ts.map +1 -0
- package/dist/standard-schema.d.ts +42 -0
- package/dist/standard-schema.d.ts.map +1 -0
- package/dist/store/create-db-store.d.ts +17 -0
- package/dist/store/create-db-store.d.ts.map +1 -0
- package/dist/store/folder-store.d.ts +36 -0
- package/dist/store/folder-store.d.ts.map +1 -0
- package/dist/store/list-cursor.d.ts +26 -4
- package/dist/store/list-cursor.d.ts.map +1 -1
- package/dist/store/map-row.d.ts +17 -8
- package/dist/store/map-row.d.ts.map +1 -1
- package/dist/store/object-store.d.ts +208 -0
- package/dist/store/object-store.d.ts.map +1 -0
- package/dist/store/schema-version.d.ts +7 -0
- package/dist/store/schema-version.d.ts.map +1 -0
- package/dist/types/client.d.ts +209 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/plugin.d.ts +112 -0
- package/dist/types/plugin.d.ts.map +1 -0
- package/dist/types/storage-object.d.ts +40 -85
- package/dist/types/storage-object.d.ts.map +1 -1
- package/package.json +51 -12
- package/prisma/dimah-s3.prisma +80 -0
- package/sql/mysql.sql +59 -0
- package/sql/pg.sql +53 -0
- package/sql/sqlite.sql +54 -0
- package/sql/upgrade/1.0.0-2.0.0/mysql.sql +71 -0
- package/sql/upgrade/1.0.0-2.0.0/pg.sql +47 -0
- package/sql/upgrade/1.0.0-2.0.0/sqlite.sql +119 -0
- package/dist/client/db-object-list-accessors.d.ts +0 -36
- package/dist/client/db-object-list-accessors.d.ts.map +0 -1
- package/dist/client/db-object-query.d.ts +0 -40
- package/dist/client/db-object-query.d.ts.map +0 -1
- package/dist/errors.d.ts +0 -6
- package/dist/errors.d.ts.map +0 -1
- package/dist/hooks/create-object-access-guard.d.ts +0 -51
- package/dist/hooks/create-object-access-guard.d.ts.map +0 -1
- package/dist/hooks/create-quota-guard.d.ts +0 -28
- package/dist/hooks/create-quota-guard.d.ts.map +0 -1
- package/dist/jobs/purge-stale-pending.d.ts +0 -31
- package/dist/jobs/purge-stale-pending.d.ts.map +0 -1
- package/dist/plugin/list-query-schema.d.ts +0 -21
- package/dist/plugin/list-query-schema.d.ts.map +0 -1
- package/dist/plugin/memoize-scope-resolver.d.ts +0 -8
- package/dist/plugin/memoize-scope-resolver.d.ts.map +0 -1
- package/dist/store/storage-object-store.d.ts +0 -137
- package/dist/store/storage-object-store.d.ts.map +0 -1
- package/src/schema/examples/README.md +0 -10
- package/src/schema/examples/drizzle.ts +0 -92
- package/src/schema/examples/schema.prisma +0 -55
|
@@ -1,107 +1,62 @@
|
|
|
1
|
-
/** Lifecycle status of a tracked object. */
|
|
2
|
-
export type StorageObjectStatus = "pending" | "active" | "deleted";
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* Lifecycle status of a tracked object.
|
|
3
|
+
* - `pending`: presigned or started, not confirmed yet
|
|
4
|
+
* - `active`: confirmed with HeadObject
|
|
5
|
+
* - `deleted`: soft-deleted
|
|
6
|
+
* - `purging`: a stale pending row that purge has claimed
|
|
6
7
|
*/
|
|
7
|
-
export type
|
|
8
|
+
export type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
|
|
9
|
+
/**
|
|
10
|
+
* A `storage_object` row as the stores return it. Sizes are numbers (S3
|
|
11
|
+
* caps an object at 5 TiB, well inside the safe integer range).
|
|
12
|
+
*/
|
|
13
|
+
export type StorageObject<TAttributes = never> = {
|
|
8
14
|
id: string;
|
|
9
|
-
/** Owner,
|
|
15
|
+
/** Owner, for example `user:123` or `org:acme`. */
|
|
10
16
|
scope: string;
|
|
11
17
|
bucket: string;
|
|
12
18
|
key: string;
|
|
13
|
-
/** Named dimah-s3 route. */
|
|
19
|
+
/** Named dimah-s3 route that created the object. */
|
|
14
20
|
route: string;
|
|
21
|
+
/** Logical folder path. `null` is the root. */
|
|
22
|
+
folder: string | null;
|
|
23
|
+
filename: string;
|
|
15
24
|
contentType: string | null;
|
|
16
|
-
/** Verified size in bytes
|
|
25
|
+
/** Verified size in bytes, set on confirm. */
|
|
17
26
|
size: number | null;
|
|
27
|
+
/** Size the client declared before confirm. Quota counts it while pending. */
|
|
28
|
+
declaredSize: number | null;
|
|
18
29
|
eTag: string | null;
|
|
19
|
-
filename: string | null;
|
|
20
30
|
status: StorageObjectStatus;
|
|
21
|
-
/**
|
|
22
|
-
|
|
31
|
+
/** S3 user metadata of the verified object. */
|
|
32
|
+
s3Metadata: Record<string, string> | null;
|
|
33
|
+
/** App attributes, validated by the plugin's `attributes.schema`. */
|
|
34
|
+
attributes: TAttributes | null;
|
|
23
35
|
acl: string | null;
|
|
24
|
-
/** Multipart upload ID while
|
|
36
|
+
/** Multipart upload ID while the row is pending. */
|
|
25
37
|
uploadId: string | null;
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Token of the upload ticket that wrote the row. While purge cleans up an
|
|
40
|
+
* unconfirmed overwrite, it carries a `purge:` prefix.
|
|
41
|
+
*/
|
|
42
|
+
uploadToken: string | null;
|
|
43
|
+
/** Confirm deadline of a pending row (the upload ticket's expiry). */
|
|
30
44
|
expiresAt: Date | null;
|
|
45
|
+
confirmedAt: Date | null;
|
|
31
46
|
createdAt: Date;
|
|
32
47
|
updatedAt: Date;
|
|
33
48
|
deletedAt: Date | null;
|
|
34
49
|
};
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
* - `upload`: presign and multipart init
|
|
38
|
-
* - `confirm`: confirm, and the confirm step of multipart complete
|
|
39
|
-
* - `multipart`: part, list, abort, and complete
|
|
40
|
-
* - `download`: presigned download and `GET /file`
|
|
41
|
-
* - `delete`: delete, and each key of a batch delete
|
|
42
|
-
* - `list`: `GET /db/objects` and `GET /db/object`
|
|
43
|
-
*/
|
|
44
|
-
export type ScopeOperation = "upload" | "confirm" | "multipart" | "download" | "delete" | "list";
|
|
45
|
-
/** Values the endpoint already validated, passed to {@link ScopeResolver}. */
|
|
46
|
-
export type ScopeContext = {
|
|
47
|
-
operation: ScopeOperation;
|
|
48
|
-
/** Named route. On `list`, set only when the client filtered by route. */
|
|
49
|
-
route?: string;
|
|
50
|
-
/** Object key. Absent on `GET /db/objects`. */
|
|
51
|
-
key?: string;
|
|
52
|
-
/** Client extras from presign or multipart init. Set on `upload` only. */
|
|
53
|
-
clientMetadata?: Record<string, string>;
|
|
54
|
-
};
|
|
55
|
-
/**
|
|
56
|
-
* Resolves the owning scope for a request (e.g. from a session cookie).
|
|
57
|
-
* `context` carries the operation, route, and key, so a scope that depends
|
|
58
|
-
* on the object key does not have to parse the request. A batch delete
|
|
59
|
-
* resolves once per key. Return `null` to reject the request as
|
|
60
|
-
* unauthenticated (401).
|
|
61
|
-
*/
|
|
62
|
-
export type ScopeResolver = (request: Request, context: ScopeContext) => string | null | Promise<string | null>;
|
|
63
|
-
/**
|
|
64
|
-
* Browser-facing object row from `GET /db/objects`.
|
|
65
|
-
* Deliberately narrower than {@link StorageObject} — omits server-only fields.
|
|
66
|
-
*/
|
|
67
|
-
export type DbClientObject = {
|
|
50
|
+
/** A `storage_folder` row. A folder exists once per scope and path. */
|
|
51
|
+
export type StorageFolder = {
|
|
68
52
|
id: string;
|
|
69
|
-
bucket: string;
|
|
70
|
-
key: string;
|
|
71
|
-
route: string;
|
|
72
|
-
filename: string | null;
|
|
73
|
-
contentType: string | null;
|
|
74
|
-
size: number | null;
|
|
75
|
-
declaredSize: number | null;
|
|
76
|
-
status: StorageObjectStatus;
|
|
77
|
-
/** ISO-8601 timestamp. */
|
|
78
|
-
createdAt: string;
|
|
79
|
-
};
|
|
80
|
-
export type DbClientListResponse = {
|
|
81
|
-
/** Scope resolved on the server via `resolveScope` (not a client input). */
|
|
82
53
|
scope: string;
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Query params for browser `api.db.listObjects`.
|
|
92
|
-
* Scope is not accepted — the server derives it from `resolveScope` on the request.
|
|
93
|
-
*/
|
|
94
|
-
export type DbClientListInput = {
|
|
95
|
-
status?: StorageObjectStatus;
|
|
96
|
-
limit?: number;
|
|
97
|
-
offset?: number;
|
|
98
|
-
cursor?: string;
|
|
99
|
-
route?: string;
|
|
100
|
-
contentType?: string;
|
|
101
|
-
prefix?: string;
|
|
102
|
-
};
|
|
103
|
-
export type DbClientGetInput = {
|
|
104
|
-
key: string;
|
|
105
|
-
bucket?: string;
|
|
54
|
+
/** Full folder path. */
|
|
55
|
+
path: string;
|
|
56
|
+
/** Path of the containing folder. `null` is the root. */
|
|
57
|
+
parent: string | null;
|
|
58
|
+
/** Last segment of `path`. */
|
|
59
|
+
name: string;
|
|
60
|
+
createdAt: Date;
|
|
106
61
|
};
|
|
107
62
|
//# sourceMappingURL=storage-object.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage-object.d.ts","sourceRoot":"","sources":["../../src/types/storage-object.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"storage-object.d.ts","sourceRoot":"","sources":["../../src/types/storage-object.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,SAAS,CAAC;AAE/E;;;GAGG;AACH,MAAM,MAAM,aAAa,CAAC,WAAW,GAAG,KAAK,IAAI;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,8CAA8C;IAC9C,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,8EAA8E;IAC9E,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,mBAAmB,CAAC;IAC5B,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC1C,qEAAqE;IACrE,UAAU,EAAE,WAAW,GAAG,IAAI,CAAC;IAC/B,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,oDAAoD;IACpD,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB;;;OAGG;IACH,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,sEAAsE;IACtE,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,IAAI,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,GAAG,IAAI,CAAC;CACxB,CAAC;AAEF,uEAAuE;AACvE,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,yDAAyD;IACzD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,8BAA8B;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimah-s3/db",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.0",
|
|
4
4
|
"description": "Optional database plugin for dimah-s3 — track S3 object ownership, listings, and resumable uploads",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"s3",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"fumadb",
|
|
19
19
|
"typescript"
|
|
20
20
|
],
|
|
21
|
-
"homepage": "https://s3.dimah.dev/docs/db",
|
|
21
|
+
"homepage": "https://v2.s3.dimah.dev/docs/db",
|
|
22
22
|
"bugs": {
|
|
23
23
|
"url": "https://github.com/dimah-kz/dimah-s3/issues"
|
|
24
24
|
},
|
|
@@ -43,44 +43,83 @@
|
|
|
43
43
|
"./cli": {
|
|
44
44
|
"types": "./dist/cli.d.ts",
|
|
45
45
|
"default": "./dist/cli.js"
|
|
46
|
+
},
|
|
47
|
+
"./drizzle/sqlite": {
|
|
48
|
+
"types": "./dist/drizzle/sqlite.d.ts",
|
|
49
|
+
"default": "./dist/drizzle/sqlite.js"
|
|
50
|
+
},
|
|
51
|
+
"./drizzle/pg": {
|
|
52
|
+
"types": "./dist/drizzle/pg.d.ts",
|
|
53
|
+
"default": "./dist/drizzle/pg.js"
|
|
54
|
+
},
|
|
55
|
+
"./drizzle/mysql": {
|
|
56
|
+
"types": "./dist/drizzle/mysql.d.ts",
|
|
57
|
+
"default": "./dist/drizzle/mysql.js"
|
|
58
|
+
},
|
|
59
|
+
"./adapters/drizzle": {
|
|
60
|
+
"types": "./dist/adapters/drizzle.d.ts",
|
|
61
|
+
"default": "./dist/adapters/drizzle.js"
|
|
62
|
+
},
|
|
63
|
+
"./adapters/kysely": {
|
|
64
|
+
"types": "./dist/adapters/kysely.d.ts",
|
|
65
|
+
"default": "./dist/adapters/kysely.js"
|
|
66
|
+
},
|
|
67
|
+
"./adapters/prisma": {
|
|
68
|
+
"types": "./dist/adapters/prisma.d.ts",
|
|
69
|
+
"default": "./dist/adapters/prisma.js"
|
|
46
70
|
}
|
|
47
71
|
},
|
|
48
72
|
"files": [
|
|
49
73
|
"dist",
|
|
50
|
-
"
|
|
74
|
+
"sql",
|
|
75
|
+
"prisma"
|
|
51
76
|
],
|
|
52
77
|
"dependencies": {
|
|
53
|
-
"@dimah-s3/core": "
|
|
78
|
+
"@dimah-s3/core": "2.0.0-beta.0",
|
|
54
79
|
"@paralleldrive/cuid2": "^3.3.0",
|
|
55
|
-
"fumadb": "
|
|
80
|
+
"fumadb": "~0.6.0",
|
|
56
81
|
"zod": "^4.6.7"
|
|
57
82
|
},
|
|
58
83
|
"devDependencies": {
|
|
59
|
-
"@aws-sdk/client-s3": "^3.
|
|
60
|
-
"@dimah-s3/
|
|
61
|
-
"@
|
|
84
|
+
"@aws-sdk/client-s3": "^3.1161.0",
|
|
85
|
+
"@dimah-s3/react": "2.0.0-beta.0",
|
|
86
|
+
"@dimah-s3/server": "2.0.0-beta.0",
|
|
87
|
+
"@electric-sql/pglite": "^0.5.14",
|
|
88
|
+
"@types/better-sqlite3": "^9.6.0",
|
|
89
|
+
"@types/node": "^26.6.6",
|
|
90
|
+
"@types/react": "^19.3.0",
|
|
62
91
|
"@workspace/eslint-config": "0.0.1",
|
|
63
92
|
"@workspace/tsup-config": "0.0.0",
|
|
64
93
|
"@workspace/typescript-config": "0.0.1",
|
|
65
94
|
"@workspace/vitest-config": "0.0.7",
|
|
95
|
+
"better-sqlite3": "^13.0.3",
|
|
66
96
|
"drizzle-orm": "1.0.0-rc.5",
|
|
67
|
-
"eslint": "^10.
|
|
68
|
-
"
|
|
97
|
+
"eslint": "^10.14.0",
|
|
98
|
+
"kysely": "^0.29.8",
|
|
99
|
+
"tsc-alias": "^1.9.10",
|
|
69
100
|
"tsup": "^9.0.0",
|
|
70
101
|
"typescript": "7.0.2",
|
|
71
102
|
"vitest": "^5.0.5"
|
|
72
103
|
},
|
|
73
104
|
"peerDependencies": {
|
|
74
105
|
"@aws-sdk/client-s3": ">=3",
|
|
75
|
-
"@dimah-s3/server": "
|
|
76
|
-
"
|
|
106
|
+
"@dimah-s3/server": "2.0.0-beta.0",
|
|
107
|
+
"@prisma/client": "^6.0.0 || ^7.0.0",
|
|
108
|
+
"drizzle-orm": ">=1.0.0-rc.5 <2.0.0",
|
|
109
|
+
"kysely": "^0.29.5"
|
|
77
110
|
},
|
|
78
111
|
"peerDependenciesMeta": {
|
|
79
112
|
"@aws-sdk/client-s3": {
|
|
80
113
|
"optional": true
|
|
81
114
|
},
|
|
115
|
+
"@prisma/client": {
|
|
116
|
+
"optional": true
|
|
117
|
+
},
|
|
82
118
|
"drizzle-orm": {
|
|
83
119
|
"optional": true
|
|
120
|
+
},
|
|
121
|
+
"kysely": {
|
|
122
|
+
"optional": true
|
|
84
123
|
}
|
|
85
124
|
},
|
|
86
125
|
"publishConfig": {
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Prisma models for @dimah-s3/db schema 2.0.0.
|
|
2
|
+
//
|
|
3
|
+
// Copy this file next to your schema (Prisma reads every .prisma file in the
|
|
4
|
+
// schema folder) or paste the models into schema.prisma, then create the
|
|
5
|
+
// client with `prismaAdapter` from `@dimah-s3/db/adapters/prisma`. Keep the
|
|
6
|
+
// model names: FumaDB calls `prisma.storageObject`, `prisma.storageFolder` and
|
|
7
|
+
// `prisma.private_dimah_s3_settings`.
|
|
8
|
+
//
|
|
9
|
+
// The models work as they are on PostgreSQL and SQLite. On MySQL, match
|
|
10
|
+
// `sql/mysql.sql`: add `@db.VarChar(1024)` to `key`, `folder`, `path` and
|
|
11
|
+
// `parent`, `@db.DateTime(3)` to the timestamps, and index prefixes such as
|
|
12
|
+
// `@@unique([bucket, key(length: 512)])`.
|
|
13
|
+
|
|
14
|
+
/// One row per tracked object: pending (presigned), active (confirmed),
|
|
15
|
+
/// deleted (soft delete), or purging (a stale pending row purge has claimed).
|
|
16
|
+
model StorageObject {
|
|
17
|
+
id String @id @default(cuid())
|
|
18
|
+
/// Owner, for example `user:123` or `org:acme`.
|
|
19
|
+
scope String
|
|
20
|
+
bucket String
|
|
21
|
+
key String
|
|
22
|
+
/// Named dimah-s3 route that created the object.
|
|
23
|
+
route String
|
|
24
|
+
/// Logical folder path. `null` is the root.
|
|
25
|
+
folder String?
|
|
26
|
+
filename String
|
|
27
|
+
contentType String? @map("content_type")
|
|
28
|
+
/// Verified size from HeadObject, set on confirm.
|
|
29
|
+
size BigInt?
|
|
30
|
+
/// Size the client declared before confirm.
|
|
31
|
+
declaredSize BigInt? @map("declared_size")
|
|
32
|
+
eTag String? @map("e_tag")
|
|
33
|
+
status String
|
|
34
|
+
/// S3 user metadata of the verified object.
|
|
35
|
+
s3Metadata Json? @map("s3_metadata")
|
|
36
|
+
/// App attributes, validated by the plugin's `attributes.schema`.
|
|
37
|
+
attributes Json?
|
|
38
|
+
acl String?
|
|
39
|
+
/// Multipart upload ID while the row is pending.
|
|
40
|
+
uploadId String? @map("upload_id")
|
|
41
|
+
/// Token of the upload ticket that wrote the row.
|
|
42
|
+
uploadToken String? @map("upload_token")
|
|
43
|
+
/// Confirm deadline of a pending row (the upload ticket's expiry).
|
|
44
|
+
expiresAt DateTime? @map("expires_at")
|
|
45
|
+
confirmedAt DateTime? @map("confirmed_at")
|
|
46
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
47
|
+
updatedAt DateTime @default(now()) @map("updated_at")
|
|
48
|
+
deletedAt DateTime? @map("deleted_at")
|
|
49
|
+
|
|
50
|
+
@@unique([bucket, key], map: "storage_object_bucket_key_uk")
|
|
51
|
+
@@index([scope, status, folder, createdAt], map: "storage_object_scope_folder_idx")
|
|
52
|
+
@@index([scope, status, updatedAt], map: "storage_object_scope_updated_idx")
|
|
53
|
+
@@index([scope, status, filename], map: "storage_object_scope_filename_idx")
|
|
54
|
+
@@index([scope, status, size], map: "storage_object_scope_size_idx")
|
|
55
|
+
@@index([status, expiresAt], map: "storage_object_status_expires_idx")
|
|
56
|
+
@@map("storage_object")
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/// One row per folder, so an empty folder still lists.
|
|
60
|
+
model StorageFolder {
|
|
61
|
+
id String @id @default(cuid())
|
|
62
|
+
scope String
|
|
63
|
+
/// Full folder path.
|
|
64
|
+
path String
|
|
65
|
+
/// Path of the containing folder. `null` is the root.
|
|
66
|
+
parent String?
|
|
67
|
+
/// Last segment of `path`.
|
|
68
|
+
name String
|
|
69
|
+
createdAt DateTime @default(now()) @map("created_at")
|
|
70
|
+
|
|
71
|
+
@@unique([scope, path], map: "storage_folder_scope_path_uk")
|
|
72
|
+
@@index([scope, parent], map: "storage_folder_scope_parent_idx")
|
|
73
|
+
@@map("storage_folder")
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/// FumaDB settings. The adapter reads the schema version from the `version` row.
|
|
77
|
+
model private_dimah_s3_settings {
|
|
78
|
+
key String @id
|
|
79
|
+
value String @default("2.0.0")
|
|
80
|
+
}
|
package/sql/mysql.sql
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
-- @dimah-s3/db schema 2.0.0 for MySQL 8.
|
|
2
|
+
-- Keys, folders, and scopes compare byte for byte (utf8mb4_bin); file names
|
|
3
|
+
-- use a case-insensitive collation for search. An InnoDB index holds at most
|
|
4
|
+
-- 3072 bytes, so `key`, `folder`, `path`, and `parent` are indexed by prefix:
|
|
5
|
+
-- two values that share their first 512 characters (255 for `folder`) share
|
|
6
|
+
-- an index entry, and the unique keys treat them as equal.
|
|
7
|
+
|
|
8
|
+
CREATE TABLE `storage_object` (
|
|
9
|
+
`id` varchar(255) NOT NULL,
|
|
10
|
+
`scope` varchar(255) NOT NULL,
|
|
11
|
+
`bucket` varchar(255) NOT NULL,
|
|
12
|
+
`key` varchar(1024) NOT NULL,
|
|
13
|
+
`route` varchar(255) NOT NULL,
|
|
14
|
+
`folder` varchar(1024),
|
|
15
|
+
`filename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
16
|
+
`content_type` varchar(255),
|
|
17
|
+
`size` bigint,
|
|
18
|
+
`declared_size` bigint,
|
|
19
|
+
`e_tag` varchar(255),
|
|
20
|
+
`status` varchar(16) NOT NULL,
|
|
21
|
+
`s3_metadata` json,
|
|
22
|
+
`attributes` json,
|
|
23
|
+
`acl` varchar(255),
|
|
24
|
+
`upload_id` text,
|
|
25
|
+
`upload_token` varchar(64),
|
|
26
|
+
`expires_at` datetime(3),
|
|
27
|
+
`confirmed_at` datetime(3),
|
|
28
|
+
`created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
29
|
+
`updated_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
30
|
+
`deleted_at` datetime(3),
|
|
31
|
+
PRIMARY KEY (`id`),
|
|
32
|
+
UNIQUE KEY `storage_object_bucket_key_uk` (`bucket`, `key`(512)),
|
|
33
|
+
KEY `storage_object_scope_folder_idx` (`scope`, `status`, `folder`(255), `created_at`),
|
|
34
|
+
KEY `storage_object_scope_updated_idx` (`scope`, `status`, `updated_at`),
|
|
35
|
+
KEY `storage_object_scope_filename_idx` (`scope`, `status`, `filename`),
|
|
36
|
+
KEY `storage_object_scope_size_idx` (`scope`, `status`, `size`),
|
|
37
|
+
KEY `storage_object_status_expires_idx` (`status`, `expires_at`)
|
|
38
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
39
|
+
|
|
40
|
+
CREATE TABLE `storage_folder` (
|
|
41
|
+
`id` varchar(255) NOT NULL,
|
|
42
|
+
`scope` varchar(255) NOT NULL,
|
|
43
|
+
`path` varchar(1024) NOT NULL,
|
|
44
|
+
`parent` varchar(1024),
|
|
45
|
+
`name` varchar(255) NOT NULL,
|
|
46
|
+
`created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
47
|
+
PRIMARY KEY (`id`),
|
|
48
|
+
UNIQUE KEY `storage_folder_scope_path_uk` (`scope`, `path`(512)),
|
|
49
|
+
KEY `storage_folder_scope_parent_idx` (`scope`, `parent`(512))
|
|
50
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
51
|
+
|
|
52
|
+
-- Schema version for the Kysely and Prisma adapters.
|
|
53
|
+
CREATE TABLE `private_dimah_s3_settings` (
|
|
54
|
+
`key` varchar(255) NOT NULL,
|
|
55
|
+
`value` text NOT NULL DEFAULT ('2.0.0'),
|
|
56
|
+
PRIMARY KEY (`key`)
|
|
57
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
58
|
+
|
|
59
|
+
INSERT INTO `private_dimah_s3_settings` (`key`, `value`) VALUES ('version', '2.0.0');
|
package/sql/pg.sql
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- @dimah-s3/db schema 2.0.0 for PostgreSQL.
|
|
2
|
+
|
|
3
|
+
CREATE TABLE "storage_object" (
|
|
4
|
+
"id" varchar(255) PRIMARY KEY NOT NULL,
|
|
5
|
+
"scope" text NOT NULL,
|
|
6
|
+
"bucket" text NOT NULL,
|
|
7
|
+
"key" text NOT NULL,
|
|
8
|
+
"route" text NOT NULL,
|
|
9
|
+
"folder" text,
|
|
10
|
+
"filename" text NOT NULL,
|
|
11
|
+
"content_type" text,
|
|
12
|
+
"size" bigint,
|
|
13
|
+
"declared_size" bigint,
|
|
14
|
+
"e_tag" text,
|
|
15
|
+
"status" text NOT NULL,
|
|
16
|
+
"s3_metadata" json,
|
|
17
|
+
"attributes" json,
|
|
18
|
+
"acl" text,
|
|
19
|
+
"upload_id" text,
|
|
20
|
+
"upload_token" text,
|
|
21
|
+
"expires_at" timestamp,
|
|
22
|
+
"confirmed_at" timestamp,
|
|
23
|
+
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
24
|
+
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
25
|
+
"deleted_at" timestamp,
|
|
26
|
+
CONSTRAINT "storage_object_bucket_key_uk" UNIQUE ("bucket", "key")
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CREATE INDEX "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "folder", "created_at");
|
|
30
|
+
CREATE INDEX "storage_object_scope_updated_idx" ON "storage_object" ("scope", "status", "updated_at");
|
|
31
|
+
CREATE INDEX "storage_object_scope_filename_idx" ON "storage_object" ("scope", "status", "filename");
|
|
32
|
+
CREATE INDEX "storage_object_scope_size_idx" ON "storage_object" ("scope", "status", "size");
|
|
33
|
+
CREATE INDEX "storage_object_status_expires_idx" ON "storage_object" ("status", "expires_at");
|
|
34
|
+
|
|
35
|
+
CREATE TABLE "storage_folder" (
|
|
36
|
+
"id" varchar(255) PRIMARY KEY NOT NULL,
|
|
37
|
+
"scope" text NOT NULL,
|
|
38
|
+
"path" text NOT NULL,
|
|
39
|
+
"parent" text,
|
|
40
|
+
"name" text NOT NULL,
|
|
41
|
+
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
+
CONSTRAINT "storage_folder_scope_path_uk" UNIQUE ("scope", "path")
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE INDEX "storage_folder_scope_parent_idx" ON "storage_folder" ("scope", "parent");
|
|
46
|
+
|
|
47
|
+
-- Schema version for the Kysely and Prisma adapters.
|
|
48
|
+
CREATE TABLE "private_dimah_s3_settings" (
|
|
49
|
+
"key" varchar(255) PRIMARY KEY NOT NULL,
|
|
50
|
+
"value" text NOT NULL DEFAULT '2.0.0'
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.0.0');
|
package/sql/sqlite.sql
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
-- @dimah-s3/db schema 2.0.0 for SQLite.
|
|
2
|
+
-- Timestamps are epoch milliseconds. Sizes are INTEGER.
|
|
3
|
+
|
|
4
|
+
CREATE TABLE "storage_object" (
|
|
5
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
6
|
+
"scope" text NOT NULL,
|
|
7
|
+
"bucket" text NOT NULL,
|
|
8
|
+
"key" text NOT NULL,
|
|
9
|
+
"route" text NOT NULL,
|
|
10
|
+
"folder" text,
|
|
11
|
+
"filename" text NOT NULL,
|
|
12
|
+
"content_type" text,
|
|
13
|
+
"size" integer,
|
|
14
|
+
"declared_size" integer,
|
|
15
|
+
"e_tag" text,
|
|
16
|
+
"status" text NOT NULL,
|
|
17
|
+
"s3_metadata" text,
|
|
18
|
+
"attributes" text,
|
|
19
|
+
"acl" text,
|
|
20
|
+
"upload_id" text,
|
|
21
|
+
"upload_token" text,
|
|
22
|
+
"expires_at" integer,
|
|
23
|
+
"confirmed_at" integer,
|
|
24
|
+
"created_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000),
|
|
25
|
+
"updated_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000),
|
|
26
|
+
"deleted_at" integer
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
CREATE UNIQUE INDEX "storage_object_bucket_key_uk" ON "storage_object" ("bucket", "key");
|
|
30
|
+
CREATE INDEX "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "folder", "created_at");
|
|
31
|
+
CREATE INDEX "storage_object_scope_updated_idx" ON "storage_object" ("scope", "status", "updated_at");
|
|
32
|
+
CREATE INDEX "storage_object_scope_filename_idx" ON "storage_object" ("scope", "status", "filename");
|
|
33
|
+
CREATE INDEX "storage_object_scope_size_idx" ON "storage_object" ("scope", "status", "size");
|
|
34
|
+
CREATE INDEX "storage_object_status_expires_idx" ON "storage_object" ("status", "expires_at");
|
|
35
|
+
|
|
36
|
+
CREATE TABLE "storage_folder" (
|
|
37
|
+
"id" text PRIMARY KEY NOT NULL,
|
|
38
|
+
"scope" text NOT NULL,
|
|
39
|
+
"path" text NOT NULL,
|
|
40
|
+
"parent" text,
|
|
41
|
+
"name" text NOT NULL,
|
|
42
|
+
"created_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000)
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
CREATE UNIQUE INDEX "storage_folder_scope_path_uk" ON "storage_folder" ("scope", "path");
|
|
46
|
+
CREATE INDEX "storage_folder_scope_parent_idx" ON "storage_folder" ("scope", "parent");
|
|
47
|
+
|
|
48
|
+
-- Schema version for the Kysely and Prisma adapters.
|
|
49
|
+
CREATE TABLE "private_dimah_s3_settings" (
|
|
50
|
+
"key" text PRIMARY KEY NOT NULL,
|
|
51
|
+
"value" text NOT NULL DEFAULT '2.0.0'
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.0.0');
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
-- @dimah-s3/db schema 1.0.0 → 2.0.0 for MySQL 8.
|
|
2
|
+
-- Back up the database first. MySQL commits each ALTER TABLE on its own, so
|
|
3
|
+
-- a failed step leaves the earlier ones applied.
|
|
4
|
+
-- - `metadata` moves to `s3_metadata`; `attributes`, `folder`, and
|
|
5
|
+
-- `upload_token` start empty (`folder` NULL is the root).
|
|
6
|
+
-- - A missing `filename` becomes the last segment of the key.
|
|
7
|
+
-- - Columns take the 2.0.0 types (see ../../mysql.sql). Timestamps become
|
|
8
|
+
-- datetime(3), converted in the session time zone: run this with the time
|
|
9
|
+
-- zone your app connects with.
|
|
10
|
+
--
|
|
11
|
+
-- If you added the 1.x recommended indexes, drop them first:
|
|
12
|
+
-- DROP INDEX `storage_object_scope_status_created_idx` ON `storage_object`;
|
|
13
|
+
-- DROP INDEX `storage_object_scope_route_idx` ON `storage_object`;
|
|
14
|
+
-- DROP INDEX `storage_object_status_created_idx` ON `storage_object`;
|
|
15
|
+
-- DROP INDEX `storage_object_status_expires_idx` ON `storage_object`;
|
|
16
|
+
|
|
17
|
+
UPDATE `storage_object`
|
|
18
|
+
SET `filename` = COALESCE(NULLIF(SUBSTRING_INDEX(`key`, '/', -1), ''), `key`)
|
|
19
|
+
WHERE `filename` IS NULL;
|
|
20
|
+
UPDATE `storage_object` SET `filename` = LEFT(`filename`, 255);
|
|
21
|
+
|
|
22
|
+
DROP INDEX `storage_object_bucket_key_uk` ON `storage_object`;
|
|
23
|
+
|
|
24
|
+
ALTER TABLE `storage_object`
|
|
25
|
+
CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;
|
|
26
|
+
|
|
27
|
+
ALTER TABLE `storage_object`
|
|
28
|
+
CHANGE `metadata` `s3_metadata` json,
|
|
29
|
+
ADD COLUMN `folder` varchar(1024),
|
|
30
|
+
ADD COLUMN `attributes` json,
|
|
31
|
+
ADD COLUMN `upload_token` varchar(64),
|
|
32
|
+
MODIFY `id` varchar(255) NOT NULL,
|
|
33
|
+
MODIFY `scope` varchar(255) NOT NULL,
|
|
34
|
+
MODIFY `bucket` varchar(255) NOT NULL,
|
|
35
|
+
MODIFY `key` varchar(1024) NOT NULL,
|
|
36
|
+
MODIFY `route` varchar(255) NOT NULL,
|
|
37
|
+
MODIFY `filename` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
|
|
38
|
+
MODIFY `content_type` varchar(255),
|
|
39
|
+
MODIFY `size` bigint,
|
|
40
|
+
MODIFY `declared_size` bigint,
|
|
41
|
+
MODIFY `e_tag` varchar(255),
|
|
42
|
+
MODIFY `status` varchar(16) NOT NULL,
|
|
43
|
+
MODIFY `acl` varchar(255),
|
|
44
|
+
MODIFY `upload_id` text,
|
|
45
|
+
MODIFY `expires_at` datetime(3),
|
|
46
|
+
MODIFY `confirmed_at` datetime(3),
|
|
47
|
+
MODIFY `created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
48
|
+
MODIFY `updated_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
49
|
+
MODIFY `deleted_at` datetime(3),
|
|
50
|
+
ADD UNIQUE KEY `storage_object_bucket_key_uk` (`bucket`, `key`(512)),
|
|
51
|
+
ADD KEY `storage_object_scope_folder_idx` (`scope`, `status`, `folder`(255), `created_at`),
|
|
52
|
+
ADD KEY `storage_object_scope_updated_idx` (`scope`, `status`, `updated_at`),
|
|
53
|
+
ADD KEY `storage_object_scope_filename_idx` (`scope`, `status`, `filename`),
|
|
54
|
+
ADD KEY `storage_object_scope_size_idx` (`scope`, `status`, `size`),
|
|
55
|
+
ADD KEY `storage_object_status_expires_idx` (`status`, `expires_at`);
|
|
56
|
+
|
|
57
|
+
CREATE TABLE `storage_folder` (
|
|
58
|
+
`id` varchar(255) NOT NULL,
|
|
59
|
+
`scope` varchar(255) NOT NULL,
|
|
60
|
+
`path` varchar(1024) NOT NULL,
|
|
61
|
+
`parent` varchar(1024),
|
|
62
|
+
`name` varchar(255) NOT NULL,
|
|
63
|
+
`created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
64
|
+
PRIMARY KEY (`id`),
|
|
65
|
+
UNIQUE KEY `storage_folder_scope_path_uk` (`scope`, `path`(512)),
|
|
66
|
+
KEY `storage_folder_scope_parent_idx` (`scope`, `parent`(512))
|
|
67
|
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
68
|
+
|
|
69
|
+
-- Kysely and Prisma read the version from this table. A Drizzle setup reads
|
|
70
|
+
-- it from the table definition instead: skip this statement there.
|
|
71
|
+
UPDATE `private_dimah_s3_settings` SET `value` = '2.0.0' WHERE `key` = 'version';
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
-- @dimah-s3/db schema 1.0.0 → 2.0.0 for PostgreSQL.
|
|
2
|
+
-- Back up the database first.
|
|
3
|
+
-- - `metadata` moves to `s3_metadata`; `attributes`, `folder`, and
|
|
4
|
+
-- `upload_token` start empty (`folder` NULL is the root).
|
|
5
|
+
-- - A missing `filename` becomes the last segment of the key.
|
|
6
|
+
-- - The 1.x recommended indexes give way to the 2.0.0 indexes.
|
|
7
|
+
|
|
8
|
+
BEGIN;
|
|
9
|
+
|
|
10
|
+
ALTER TABLE "storage_object" RENAME COLUMN "metadata" TO "s3_metadata";
|
|
11
|
+
ALTER TABLE "storage_object"
|
|
12
|
+
ADD COLUMN "folder" text,
|
|
13
|
+
ADD COLUMN "attributes" json,
|
|
14
|
+
ADD COLUMN "upload_token" text;
|
|
15
|
+
|
|
16
|
+
UPDATE "storage_object"
|
|
17
|
+
SET "filename" = COALESCE(NULLIF(substring("key" from '[^/]*$'), ''), "key")
|
|
18
|
+
WHERE "filename" IS NULL;
|
|
19
|
+
ALTER TABLE "storage_object" ALTER COLUMN "filename" SET NOT NULL;
|
|
20
|
+
|
|
21
|
+
DROP INDEX IF EXISTS "storage_object_scope_status_created_idx";
|
|
22
|
+
DROP INDEX IF EXISTS "storage_object_scope_route_idx";
|
|
23
|
+
DROP INDEX IF EXISTS "storage_object_status_created_idx";
|
|
24
|
+
|
|
25
|
+
CREATE INDEX IF NOT EXISTS "storage_object_scope_folder_idx" ON "storage_object" ("scope", "status", "folder", "created_at");
|
|
26
|
+
CREATE INDEX IF NOT EXISTS "storage_object_scope_updated_idx" ON "storage_object" ("scope", "status", "updated_at");
|
|
27
|
+
CREATE INDEX IF NOT EXISTS "storage_object_scope_filename_idx" ON "storage_object" ("scope", "status", "filename");
|
|
28
|
+
CREATE INDEX IF NOT EXISTS "storage_object_scope_size_idx" ON "storage_object" ("scope", "status", "size");
|
|
29
|
+
CREATE INDEX IF NOT EXISTS "storage_object_status_expires_idx" ON "storage_object" ("status", "expires_at");
|
|
30
|
+
|
|
31
|
+
CREATE TABLE "storage_folder" (
|
|
32
|
+
"id" varchar(255) PRIMARY KEY NOT NULL,
|
|
33
|
+
"scope" text NOT NULL,
|
|
34
|
+
"path" text NOT NULL,
|
|
35
|
+
"parent" text,
|
|
36
|
+
"name" text NOT NULL,
|
|
37
|
+
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
38
|
+
CONSTRAINT "storage_folder_scope_path_uk" UNIQUE ("scope", "path")
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE INDEX "storage_folder_scope_parent_idx" ON "storage_folder" ("scope", "parent");
|
|
42
|
+
|
|
43
|
+
COMMIT;
|
|
44
|
+
|
|
45
|
+
-- Kysely and Prisma read the version from this table. A Drizzle setup reads
|
|
46
|
+
-- it from the table definition instead: skip this statement there.
|
|
47
|
+
UPDATE "private_dimah_s3_settings" SET "value" = '2.0.0' WHERE "key" = 'version';
|