@dimah-s3/db 2.0.0-beta.0 → 2.0.0-beta.10
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 +19 -10
- package/dist/adapters/drizzle.d.ts +2 -2
- package/dist/adapters/kysely.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/cli.d.ts +18 -14
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +69 -153
- package/dist/cli.js.map +1 -1
- package/dist/client/db-client.d.ts +1 -1
- package/dist/client/db-client.d.ts.map +1 -1
- package/dist/client/db-object-source.d.ts +15 -9
- package/dist/client/db-object-source.d.ts.map +1 -1
- package/dist/client/index.d.ts +3 -3
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +101 -21
- package/dist/client/index.js.map +1 -1
- package/dist/folder-path.d.ts +17 -4
- package/dist/folder-path.d.ts.map +1 -1
- package/dist/fuma-db.d.ts +22 -43
- package/dist/fuma-db.d.ts.map +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +606 -314
- package/dist/index.js.map +1 -1
- package/dist/plugin/create-database-endpoints.d.ts +46 -22
- package/dist/plugin/create-database-endpoints.d.ts.map +1 -1
- package/dist/plugin/create-database-lifecycle-hooks.d.ts +4 -4
- package/dist/plugin/create-database-lifecycle-hooks.d.ts.map +1 -1
- package/dist/plugin/db.d.ts +2 -2
- package/dist/plugin/db.d.ts.map +1 -1
- package/dist/plugin/object-access.d.ts +2 -2
- package/dist/plugin/object-access.d.ts.map +1 -1
- package/dist/plugin/public-stores.d.ts +5 -8
- package/dist/plugin/public-stores.d.ts.map +1 -1
- package/dist/plugin/quota.d.ts +1 -1
- package/dist/plugin/schemas.d.ts +25 -11
- package/dist/plugin/schemas.d.ts.map +1 -1
- package/dist/plugin/scope.d.ts +2 -0
- package/dist/plugin/scope.d.ts.map +1 -1
- package/dist/plugin/to-db-client-object.d.ts.map +1 -1
- package/dist/schema/schema.d.ts +72 -0
- package/dist/schema/schema.d.ts.map +1 -0
- package/dist/store/create-db-store.d.ts +4 -4
- package/dist/store/create-db-store.d.ts.map +1 -1
- package/dist/store/folder-store.d.ts +73 -15
- package/dist/store/folder-store.d.ts.map +1 -1
- package/dist/store/list-cursor.d.ts +3 -1
- package/dist/store/list-cursor.d.ts.map +1 -1
- package/dist/store/map-row.d.ts +3 -9
- package/dist/store/map-row.d.ts.map +1 -1
- package/dist/store/object-store.d.ts +24 -14
- package/dist/store/object-store.d.ts.map +1 -1
- package/dist/store/schema-version.d.ts +1 -1
- package/dist/store/search-name.d.ts +7 -0
- package/dist/store/search-name.d.ts.map +1 -0
- package/dist/types/client.d.ts +114 -23
- package/dist/types/client.d.ts.map +1 -1
- package/dist/types/plugin.d.ts +17 -6
- package/dist/types/plugin.d.ts.map +1 -1
- package/dist/types/storage-object.d.ts +8 -7
- package/dist/types/storage-object.d.ts.map +1 -1
- package/package.json +15 -30
- package/dist/drizzle/mysql.d.ts +0 -1024
- package/dist/drizzle/mysql.d.ts.map +0 -1
- package/dist/drizzle/mysql.js +0 -123
- package/dist/drizzle/mysql.js.map +0 -1
- package/dist/drizzle/pg.d.ts +0 -963
- package/dist/drizzle/pg.d.ts.map +0 -1
- package/dist/drizzle/pg.js +0 -104
- package/dist/drizzle/pg.js.map +0 -1
- package/dist/drizzle/shared.d.ts +0 -16
- package/dist/drizzle/shared.d.ts.map +0 -1
- package/dist/drizzle/sqlite.d.ts +0 -1023
- package/dist/drizzle/sqlite.d.ts.map +0 -1
- package/dist/drizzle/sqlite.js +0 -107
- package/dist/drizzle/sqlite.js.map +0 -1
- package/dist/schema/v1.d.ts +0 -24
- package/dist/schema/v1.d.ts.map +0 -1
- package/dist/schema/v2.d.ts +0 -64
- package/dist/schema/v2.d.ts.map +0 -1
- package/prisma/dimah-s3.prisma +0 -80
- package/sql/mysql.sql +0 -59
- package/sql/pg.sql +0 -53
- package/sql/sqlite.sql +0 -54
- package/sql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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIzB,CAAC"}
|
package/dist/drizzle/sqlite.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { sql } from 'drizzle-orm';
|
|
2
|
-
import { sqliteTable, text, uniqueIndex, index, integer } from 'drizzle-orm/sqlite-core';
|
|
3
|
-
import { createId } from '@paralleldrive/cuid2';
|
|
4
|
-
|
|
5
|
-
// src/drizzle/sqlite.ts
|
|
6
|
-
var DIMAH_S3_SCHEMA_VERSION = "2.0.0";
|
|
7
|
-
var runtimeDefaults = {
|
|
8
|
-
id: () => createId(),
|
|
9
|
-
now: () => /* @__PURE__ */ new Date()
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// src/drizzle/sqlite.ts
|
|
13
|
-
function id() {
|
|
14
|
-
return text("id").primaryKey().$defaultFn(runtimeDefaults.id);
|
|
15
|
-
}
|
|
16
|
-
function timestamp(name) {
|
|
17
|
-
return integer(name, { mode: "timestamp_ms" });
|
|
18
|
-
}
|
|
19
|
-
function timestampNow(name) {
|
|
20
|
-
return timestamp(name).notNull().default(sql`(strftime('%s', 'now') * 1000)`).$defaultFn(runtimeDefaults.now);
|
|
21
|
-
}
|
|
22
|
-
function byteCount(name) {
|
|
23
|
-
return integer(name, { mode: "number" });
|
|
24
|
-
}
|
|
25
|
-
var storageObject = sqliteTable(
|
|
26
|
-
"storage_object",
|
|
27
|
-
{
|
|
28
|
-
id: id(),
|
|
29
|
-
scope: text("scope").notNull(),
|
|
30
|
-
bucket: text("bucket").notNull(),
|
|
31
|
-
key: text("key").notNull(),
|
|
32
|
-
route: text("route").notNull(),
|
|
33
|
-
folder: text("folder"),
|
|
34
|
-
filename: text("filename").notNull(),
|
|
35
|
-
contentType: text("content_type"),
|
|
36
|
-
size: byteCount("size"),
|
|
37
|
-
declaredSize: byteCount("declared_size"),
|
|
38
|
-
eTag: text("e_tag"),
|
|
39
|
-
status: text("status").$type().notNull(),
|
|
40
|
-
s3Metadata: text("s3_metadata", { mode: "json" }).$type(),
|
|
41
|
-
attributes: text("attributes", { mode: "json" }),
|
|
42
|
-
acl: text("acl"),
|
|
43
|
-
uploadId: text("upload_id"),
|
|
44
|
-
uploadToken: text("upload_token"),
|
|
45
|
-
expiresAt: timestamp("expires_at"),
|
|
46
|
-
confirmedAt: timestamp("confirmed_at"),
|
|
47
|
-
createdAt: timestampNow("created_at"),
|
|
48
|
-
updatedAt: timestampNow("updated_at"),
|
|
49
|
-
deletedAt: timestamp("deleted_at")
|
|
50
|
-
},
|
|
51
|
-
(table) => [
|
|
52
|
-
uniqueIndex("storage_object_bucket_key_uk").on(table.bucket, table.key),
|
|
53
|
-
index("storage_object_scope_folder_idx").on(
|
|
54
|
-
table.scope,
|
|
55
|
-
table.status,
|
|
56
|
-
table.folder,
|
|
57
|
-
table.createdAt
|
|
58
|
-
),
|
|
59
|
-
index("storage_object_scope_updated_idx").on(
|
|
60
|
-
table.scope,
|
|
61
|
-
table.status,
|
|
62
|
-
table.updatedAt
|
|
63
|
-
),
|
|
64
|
-
index("storage_object_scope_filename_idx").on(
|
|
65
|
-
table.scope,
|
|
66
|
-
table.status,
|
|
67
|
-
table.filename
|
|
68
|
-
),
|
|
69
|
-
index("storage_object_scope_size_idx").on(
|
|
70
|
-
table.scope,
|
|
71
|
-
table.status,
|
|
72
|
-
table.size
|
|
73
|
-
),
|
|
74
|
-
index("storage_object_status_expires_idx").on(
|
|
75
|
-
table.status,
|
|
76
|
-
table.expiresAt
|
|
77
|
-
)
|
|
78
|
-
]
|
|
79
|
-
);
|
|
80
|
-
var storageFolder = sqliteTable(
|
|
81
|
-
"storage_folder",
|
|
82
|
-
{
|
|
83
|
-
id: id(),
|
|
84
|
-
scope: text("scope").notNull(),
|
|
85
|
-
path: text("path").notNull(),
|
|
86
|
-
parent: text("parent"),
|
|
87
|
-
name: text("name").notNull(),
|
|
88
|
-
createdAt: timestampNow("created_at")
|
|
89
|
-
},
|
|
90
|
-
(table) => [
|
|
91
|
-
uniqueIndex("storage_folder_scope_path_uk").on(table.scope, table.path),
|
|
92
|
-
index("storage_folder_scope_parent_idx").on(table.scope, table.parent)
|
|
93
|
-
]
|
|
94
|
-
);
|
|
95
|
-
var dimahS3Settings = sqliteTable("private_dimah_s3_settings", {
|
|
96
|
-
key: text("key").primaryKey(),
|
|
97
|
-
version: text("value").notNull().default(DIMAH_S3_SCHEMA_VERSION)
|
|
98
|
-
});
|
|
99
|
-
var dimahS3Tables = {
|
|
100
|
-
storageObject,
|
|
101
|
-
storageFolder,
|
|
102
|
-
private_dimah_s3_settings: dimahS3Settings
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
export { dimahS3Settings, dimahS3Tables, storageFolder, storageObject };
|
|
106
|
-
//# sourceMappingURL=sqlite.js.map
|
|
107
|
-
//# sourceMappingURL=sqlite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/drizzle/shared.ts","../../src/drizzle/sqlite.ts"],"names":[],"mappings":";;;;;AAMO,IAAM,uBAAA,GAA0B,OAAA;AAQhC,IAAM,eAAA,GAAkB;AAAA,EAC7B,EAAA,EAAI,MAAM,QAAA,EAAS;AAAA,EACnB,GAAA,EAAK,sBAAM,IAAI,IAAA;AACjB,CAAA;;;ACFA,SAAS,EAAA,GAAK;AACZ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mCAAmC,CAAA,CAAE,EAAA;AAAA,MACzC,KAAA,CAAM,MAAA;AAAA,MACN,KAAA,CAAM;AAAA;AACR;AAEJ;AAGO,IAAM,aAAA,GAAgB,WAAA;AAAA,EAC3B,gBAAA;AAAA,EACA;AAAA,IACE,IAAI,EAAA,EAAG;AAAA,IACP,KAAA,EAAO,IAAA,CAAK,OAAO,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC7B,IAAA,EAAM,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC3B,MAAA,EAAQ,KAAK,QAAQ,CAAA;AAAA,IACrB,IAAA,EAAM,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC3B,SAAA,EAAW,aAAa,YAAY;AAAA,GACtC;AAAA,EACA,CAAC,KAAA,KAAU;AAAA,IACT,YAAY,8BAA8B,CAAA,CAAE,GAAG,KAAA,CAAM,KAAA,EAAO,MAAM,IAAI,CAAA;AAAA,IACtE,MAAM,iCAAiC,CAAA,CAAE,GAAG,KAAA,CAAM,KAAA,EAAO,MAAM,MAAM;AAAA;AAEzE;AAMO,IAAM,eAAA,GAAkB,YAAY,2BAAA,EAA6B;AAAA,EACtE,GAAA,EAAK,IAAA,CAAK,KAAK,CAAA,CAAE,UAAA,EAAW;AAAA,EAC5B,SAAS,IAAA,CAAK,OAAO,EAAE,OAAA,EAAQ,CAAE,QAAQ,uBAAuB;AAClE,CAAC;AAOM,IAAM,aAAA,GAAgB;AAAA,EAC3B,aAAA;AAAA,EACA,aAAA;AAAA,EACA,yBAAA,EAA2B;AAC7B","file":"sqlite.js","sourcesContent":["import { createId } from \"@paralleldrive/cuid2\";\n\n/**\n * Schema version the Drizzle tables describe. The parity test checks it\n * against the FumaDB schema.\n */\nexport const DIMAH_S3_SCHEMA_VERSION = \"2.0.0\";\n\n/**\n * The FumaDB Drizzle adapter leaves runtime defaults to Drizzle, so the\n * tables fill ids and timestamps the way the other adapters do: a cuid and\n * the app's clock. The SQL defaults only keep generated DDL in line with\n * `sql/<dialect>.sql`.\n */\nexport const runtimeDefaults = {\n id: () => createId(),\n now: () => new Date(),\n};\n","/**\n * Drizzle tables for @dimah-s3/db schema 2.0.0 on SQLite. They match\n * `sql/sqlite.sql`: timestamps are epoch milliseconds and sizes are integers.\n */\nimport { sql } from \"drizzle-orm\";\nimport {\n index,\n integer,\n sqliteTable,\n text,\n uniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\nimport type { StorageObjectStatus } from \"@/types/storage-object\";\nimport { DIMAH_S3_SCHEMA_VERSION, runtimeDefaults } from \"./shared\";\n\nfunction id() {\n return text(\"id\").primaryKey().$defaultFn(runtimeDefaults.id);\n}\n\nfunction timestamp(name: string) {\n return integer(name, { mode: \"timestamp_ms\" });\n}\n\nfunction timestampNow(name: string) {\n return timestamp(name)\n .notNull()\n .default(sql`(strftime('%s', 'now') * 1000)`)\n .$defaultFn(runtimeDefaults.now);\n}\n\nfunction byteCount(name: string) {\n return integer(name, { mode: \"number\" });\n}\n\n/** The `storage_object` table: one row per tracked object. */\nexport const storageObject = sqliteTable(\n \"storage_object\",\n {\n id: id(),\n scope: text(\"scope\").notNull(),\n bucket: text(\"bucket\").notNull(),\n key: text(\"key\").notNull(),\n route: text(\"route\").notNull(),\n folder: text(\"folder\"),\n filename: text(\"filename\").notNull(),\n contentType: text(\"content_type\"),\n size: byteCount(\"size\"),\n declaredSize: byteCount(\"declared_size\"),\n eTag: text(\"e_tag\"),\n status: text(\"status\").$type<StorageObjectStatus>().notNull(),\n s3Metadata: text(\"s3_metadata\", { mode: \"json\" }).$type<\n Record<string, string>\n >(),\n attributes: text(\"attributes\", { mode: \"json\" }),\n acl: text(\"acl\"),\n uploadId: text(\"upload_id\"),\n uploadToken: text(\"upload_token\"),\n expiresAt: timestamp(\"expires_at\"),\n confirmedAt: timestamp(\"confirmed_at\"),\n createdAt: timestampNow(\"created_at\"),\n updatedAt: timestampNow(\"updated_at\"),\n deletedAt: timestamp(\"deleted_at\"),\n },\n (table) => [\n uniqueIndex(\"storage_object_bucket_key_uk\").on(table.bucket, table.key),\n index(\"storage_object_scope_folder_idx\").on(\n table.scope,\n table.status,\n table.folder,\n table.createdAt,\n ),\n index(\"storage_object_scope_updated_idx\").on(\n table.scope,\n table.status,\n table.updatedAt,\n ),\n index(\"storage_object_scope_filename_idx\").on(\n table.scope,\n table.status,\n table.filename,\n ),\n index(\"storage_object_scope_size_idx\").on(\n table.scope,\n table.status,\n table.size,\n ),\n index(\"storage_object_status_expires_idx\").on(\n table.status,\n table.expiresAt,\n ),\n ],\n);\n\n/** The `storage_folder` table: one row per folder, so empty folders list. */\nexport const storageFolder = sqliteTable(\n \"storage_folder\",\n {\n id: id(),\n scope: text(\"scope\").notNull(),\n path: text(\"path\").notNull(),\n parent: text(\"parent\"),\n name: text(\"name\").notNull(),\n createdAt: timestampNow(\"created_at\"),\n },\n (table) => [\n uniqueIndex(\"storage_folder_scope_path_uk\").on(table.scope, table.path),\n index(\"storage_folder_scope_parent_idx\").on(table.scope, table.parent),\n ],\n);\n\n/**\n * The FumaDB settings table. The Drizzle adapter reads the schema version\n * from the default of its `version` column, which is stored as `value`.\n */\nexport const dimahS3Settings = sqliteTable(\"private_dimah_s3_settings\", {\n key: text(\"key\").primaryKey(),\n version: text(\"value\").notNull().default(DIMAH_S3_SCHEMA_VERSION),\n});\n\n/**\n * Every @dimah-s3/db table. Spread it into your Drizzle schema and keep its\n * keys, because the FumaDB Drizzle adapter finds tables by them:\n * `drizzle({ client, relations: defineRelations({ ...dimahS3Tables }) })`.\n */\nexport const dimahS3Tables = {\n storageObject,\n storageFolder,\n private_dimah_s3_settings: dimahS3Settings,\n};\n"]}
|
package/dist/schema/v1.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export declare const v1: import("fumadb/schema").Schema<"1.0.0", {
|
|
2
|
-
storageObject: import("fumadb/schema").Table<{
|
|
3
|
-
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
4
|
-
scope: import("fumadb/schema").Column<"string", string, string>;
|
|
5
|
-
bucket: import("fumadb/schema").Column<"string", string, string>;
|
|
6
|
-
key: import("fumadb/schema").Column<"string", string, string>;
|
|
7
|
-
route: import("fumadb/schema").Column<"string", string, string>;
|
|
8
|
-
contentType: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
9
|
-
size: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
10
|
-
eTag: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
11
|
-
filename: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
12
|
-
status: import("fumadb/schema").Column<"string", string, string>;
|
|
13
|
-
s3Metadata: import("fumadb/schema").Column<"json", unknown, unknown>;
|
|
14
|
-
acl: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
15
|
-
uploadId: import("fumadb/schema").Column<"string", string | null, string | null>;
|
|
16
|
-
declaredSize: import("fumadb/schema").Column<"bigint", bigint | null, bigint | null>;
|
|
17
|
-
confirmedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
18
|
-
expiresAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
19
|
-
createdAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
20
|
-
updatedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date>;
|
|
21
|
-
deletedAt: import("fumadb/schema").Column<"timestamp", Date | null, Date | null>;
|
|
22
|
-
}, {}>;
|
|
23
|
-
}>;
|
|
24
|
-
//# sourceMappingURL=v1.d.ts.map
|
package/dist/schema/v1.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/schema/v1.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;EAKb,CAAC"}
|
package/dist/schema/v2.d.ts
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { type Column } from "fumadb/schema";
|
|
2
|
-
/** A secondary index, by SQL table and column names. */
|
|
3
|
-
export type SchemaIndex = {
|
|
4
|
-
name: string;
|
|
5
|
-
table: "storage_object" | "storage_folder";
|
|
6
|
-
columns: readonly string[];
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* Secondary indexes of schema 2.0.0. FumaDB cannot declare them, so the SQL
|
|
10
|
-
* files, the Drizzle tables, and the Prisma schema carry them.
|
|
11
|
-
*/
|
|
12
|
-
export declare const v2Indexes: readonly SchemaIndex[];
|
|
13
|
-
/**
|
|
14
|
-
* Schema 2.0.0: logical folders (`folder` plus `storage_folder`), S3 metadata
|
|
15
|
-
* split from typed `attributes`, the upload token, and the sort indexes.
|
|
16
|
-
*/
|
|
17
|
-
export declare const v2: import("fumadb/schema").Schema<"2.0.0", {
|
|
18
|
-
storageObject: import("fumadb/schema").Table<{
|
|
19
|
-
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
20
|
-
/** Owner, for example `user:123` or `org:acme`. */
|
|
21
|
-
scope: Column<"string", string, string>;
|
|
22
|
-
bucket: Column<"string", string, string>;
|
|
23
|
-
key: Column<"string", string, string>;
|
|
24
|
-
/** Named dimah-s3 route that created the object. */
|
|
25
|
-
route: Column<"string", string, string>;
|
|
26
|
-
/** Logical folder path. `null` is the root. */
|
|
27
|
-
folder: Column<"string", string | null, string | null>;
|
|
28
|
-
filename: Column<"string", string, string>;
|
|
29
|
-
contentType: Column<"string", string | null, string | null>;
|
|
30
|
-
/** Verified size from HeadObject, set on confirm. */
|
|
31
|
-
size: Column<"bigint", number | null, string | number | bigint | null>;
|
|
32
|
-
/** Size the client declared before confirm. Quota counts it while pending. */
|
|
33
|
-
declaredSize: Column<"bigint", number | null, string | number | bigint | null>;
|
|
34
|
-
eTag: Column<"string", string | null, string | null>;
|
|
35
|
-
status: Column<"string", string, string>;
|
|
36
|
-
/** S3 user metadata of the verified object. */
|
|
37
|
-
s3Metadata: Column<"json", unknown, unknown>;
|
|
38
|
-
/** App attributes, validated by the plugin's `attributes.schema`. */
|
|
39
|
-
attributes: Column<"json", unknown, unknown>;
|
|
40
|
-
acl: Column<"string", string | null, string | null>;
|
|
41
|
-
/** Multipart upload ID while the row is pending. */
|
|
42
|
-
uploadId: Column<"string", string | null, string | null>;
|
|
43
|
-
/** Token of the upload ticket that wrote the row. Confirm and purge match it. */
|
|
44
|
-
uploadToken: Column<"string", string | null, string | null>;
|
|
45
|
-
/** Confirm deadline of a pending row (the upload ticket's expiry). */
|
|
46
|
-
expiresAt: Column<"timestamp", Date | null, Date | null>;
|
|
47
|
-
confirmedAt: Column<"timestamp", Date | null, Date | null>;
|
|
48
|
-
createdAt: Column<"timestamp", Date | null, Date>;
|
|
49
|
-
updatedAt: Column<"timestamp", Date | null, Date>;
|
|
50
|
-
deletedAt: Column<"timestamp", Date | null, Date | null>;
|
|
51
|
-
}, {}>;
|
|
52
|
-
storageFolder: import("fumadb/schema").Table<{
|
|
53
|
-
id: import("fumadb/schema").IdColumn<"varchar(255)", string | null, string>;
|
|
54
|
-
scope: Column<"string", string, string>;
|
|
55
|
-
/** Full folder path. */
|
|
56
|
-
path: Column<"string", string, string>;
|
|
57
|
-
/** Path of the containing folder. `null` is the root. */
|
|
58
|
-
parent: Column<"string", string | null, string | null>;
|
|
59
|
-
/** Last segment of `path`. */
|
|
60
|
-
name: Column<"string", string, string>;
|
|
61
|
-
createdAt: Column<"timestamp", Date | null, Date>;
|
|
62
|
-
}, {}>;
|
|
63
|
-
}>;
|
|
64
|
-
//# sourceMappingURL=v2.d.ts.map
|
package/dist/schema/v2.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"v2.d.ts","sourceRoot":"","sources":["../../src/schema/v2.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAuE7E,wDAAwD;AACxD,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;CAC5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,EAAE,SAAS,WAAW,EA+B3C,CAAC;AAyCF;;;GAGG;AACH,eAAO,MAAM,EAAE;;;QArIb,mDAAmD;;;;QAInD,oDAAoD;;QAEpD,+CAA+C;;;;QAI/C,qDAAqD;;QAErD,8EAA8E;;;;QAI9E,+CAA+C;;QAE/C,qEAAqE;;;QAGrE,oDAAoD;;QAEpD,iFAAiF;;QAEjF,sEAAsE;;;;;;;;;;QAYtE,wBAAwB;;QAExB,yDAAyD;;QAEzD,8BAA8B;;;;EAqG9B,CAAC"}
|
package/prisma/dimah-s3.prisma
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
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');
|
|
@@ -1,71 +0,0 @@
|
|
|
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';
|
|
@@ -1,47 +0,0 @@
|
|
|
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';
|