@dimah-s3/db 2.0.0-beta.4 → 2.0.0-beta.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/README.md +15 -6
- package/dist/adapters/drizzle.d.ts +2 -3
- package/dist/adapters/drizzle.d.ts.map +1 -1
- package/dist/adapters/kysely.d.ts +1 -1
- package/dist/adapters/prisma.d.ts +1 -1
- package/dist/cli.d.ts +17 -12
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +41 -74
- package/dist/cli.js.map +1 -1
- package/dist/fuma-db.d.ts +19 -22
- package/dist/fuma-db.d.ts.map +1 -1
- package/dist/index.js +59 -79
- package/dist/index.js.map +1 -1
- package/dist/schema/schema.d.ts +30 -50
- package/dist/schema/schema.d.ts.map +1 -1
- package/dist/store/folder-store.d.ts.map +1 -1
- package/dist/store/map-row.d.ts +2 -8
- package/dist/store/map-row.d.ts.map +1 -1
- package/dist/store/object-store.d.ts.map +1 -1
- package/package.json +9 -27
- package/dist/drizzle/mysql.d.ts +0 -1057
- package/dist/drizzle/mysql.d.ts.map +0 -1
- package/dist/drizzle/mysql.js +0 -120
- package/dist/drizzle/mysql.js.map +0 -1
- package/dist/drizzle/pg.d.ts +0 -994
- 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 -7
- package/dist/drizzle/shared.d.ts.map +0 -1
- package/dist/drizzle/sqlite.d.ts +0 -1056
- 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/prisma/dimah-s3.prisma +0 -81
- package/sql/mysql.sql +0 -60
- package/sql/pg.sql +0 -53
- package/sql/sqlite.sql +0 -55
- package/src/drizzle/mysql.ts +0 -175
- package/src/drizzle/pg.ts +0 -146
- package/src/drizzle/sqlite.ts +0 -150
|
@@ -1 +0,0 @@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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAIzB,CAAC"}
|
package/dist/drizzle/sqlite.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { createId } from '@paralleldrive/cuid2';
|
|
2
|
-
import { sql } from 'drizzle-orm';
|
|
3
|
-
import { sqliteTable, text, uniqueIndex, index, integer } from 'drizzle-orm/sqlite-core';
|
|
4
|
-
|
|
5
|
-
// src/drizzle/sqlite.ts
|
|
6
|
-
var SCHEMA_VERSION = "2.1.0";
|
|
7
|
-
function id() {
|
|
8
|
-
return text("id").primaryKey().$defaultFn(() => createId());
|
|
9
|
-
}
|
|
10
|
-
function timestamp(name) {
|
|
11
|
-
return integer(name, { mode: "timestamp_ms" });
|
|
12
|
-
}
|
|
13
|
-
function timestampNow(name) {
|
|
14
|
-
return timestamp(name).notNull().default(sql`(strftime('%s', 'now') * 1000)`).$defaultFn(() => /* @__PURE__ */ new Date());
|
|
15
|
-
}
|
|
16
|
-
function byteCount(name) {
|
|
17
|
-
return integer(name, { mode: "number" });
|
|
18
|
-
}
|
|
19
|
-
var storageObject = sqliteTable(
|
|
20
|
-
"storage_object",
|
|
21
|
-
{
|
|
22
|
-
id: id(),
|
|
23
|
-
scope: text("scope").notNull(),
|
|
24
|
-
bucket: text("bucket").notNull(),
|
|
25
|
-
key: text("key").notNull(),
|
|
26
|
-
route: text("route").notNull(),
|
|
27
|
-
folderId: text("folder_id"),
|
|
28
|
-
filename: text("filename").notNull(),
|
|
29
|
-
contentType: text("content_type"),
|
|
30
|
-
size: byteCount("size"),
|
|
31
|
-
declaredSize: byteCount("declared_size"),
|
|
32
|
-
eTag: text("e_tag"),
|
|
33
|
-
status: text("status").$type().notNull(),
|
|
34
|
-
s3Metadata: text("s3_metadata", { mode: "json" }).$type(),
|
|
35
|
-
attributes: text("attributes", { mode: "json" }),
|
|
36
|
-
acl: text("acl"),
|
|
37
|
-
uploadId: text("upload_id"),
|
|
38
|
-
uploadToken: text("upload_token"),
|
|
39
|
-
expiresAt: timestamp("expires_at"),
|
|
40
|
-
confirmedAt: timestamp("confirmed_at"),
|
|
41
|
-
createdAt: timestampNow("created_at"),
|
|
42
|
-
updatedAt: timestampNow("updated_at"),
|
|
43
|
-
deletedAt: timestamp("deleted_at")
|
|
44
|
-
},
|
|
45
|
-
(table) => [
|
|
46
|
-
uniqueIndex("storage_object_bucket_key_uk").on(table.bucket, table.key),
|
|
47
|
-
index("storage_object_scope_folder_idx").on(
|
|
48
|
-
table.scope,
|
|
49
|
-
table.status,
|
|
50
|
-
table.folderId,
|
|
51
|
-
table.createdAt
|
|
52
|
-
),
|
|
53
|
-
index("storage_object_scope_updated_idx").on(
|
|
54
|
-
table.scope,
|
|
55
|
-
table.status,
|
|
56
|
-
table.updatedAt
|
|
57
|
-
),
|
|
58
|
-
index("storage_object_scope_filename_idx").on(
|
|
59
|
-
table.scope,
|
|
60
|
-
table.status,
|
|
61
|
-
table.filename
|
|
62
|
-
),
|
|
63
|
-
index("storage_object_scope_size_idx").on(
|
|
64
|
-
table.scope,
|
|
65
|
-
table.status,
|
|
66
|
-
table.size
|
|
67
|
-
),
|
|
68
|
-
index("storage_object_status_expires_idx").on(
|
|
69
|
-
table.status,
|
|
70
|
-
table.expiresAt
|
|
71
|
-
)
|
|
72
|
-
]
|
|
73
|
-
);
|
|
74
|
-
var storageFolder = sqliteTable(
|
|
75
|
-
"storage_folder",
|
|
76
|
-
{
|
|
77
|
-
id: id(),
|
|
78
|
-
scope: text("scope").notNull(),
|
|
79
|
-
/** `""` is the root. */
|
|
80
|
-
parentId: text("parent_id").notNull().default(""),
|
|
81
|
-
name: text("name").notNull(),
|
|
82
|
-
path: text("path").notNull(),
|
|
83
|
-
createdAt: timestampNow("created_at"),
|
|
84
|
-
updatedAt: timestampNow("updated_at")
|
|
85
|
-
},
|
|
86
|
-
(table) => [
|
|
87
|
-
uniqueIndex("storage_folder_scope_path_uk").on(table.scope, table.path),
|
|
88
|
-
uniqueIndex("storage_folder_scope_parent_name_uk").on(
|
|
89
|
-
table.scope,
|
|
90
|
-
table.parentId,
|
|
91
|
-
table.name
|
|
92
|
-
)
|
|
93
|
-
]
|
|
94
|
-
);
|
|
95
|
-
var dimahS3Settings = sqliteTable("private_dimah_s3_settings", {
|
|
96
|
-
key: text("key").primaryKey(),
|
|
97
|
-
version: text("value").notNull().default(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/sqlite.ts"],"names":[],"mappings":";;;;;AA0BA,IAAM,cAAA,GAAiB,OAAA;AAEvB,SAAS,EAAA,GAAK;AACZ,EAAA,OAAO,IAAA,CAAK,IAAI,CAAA,CACb,UAAA,GACA,UAAA,CAAW,MAAM,UAAU,CAAA;AAChC;AAEA,SAAS,UAAU,IAAA,EAAc;AAC/B,EAAA,OAAO,OAAA,CAAQ,IAAA,EAAM,EAAE,IAAA,EAAM,gBAAgB,CAAA;AAC/C;AAEA,SAAS,aAAa,IAAA,EAAc;AAClC,EAA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AA,CAAE,OAAA,EAAQ;AAAA;AAAA,IAE7B,UAAU,IAAA,CAAK,WAAW,EAAE,OAAA,EAAQ,CAAE,QAAQ,EAAE,CAAA;AAAA,IAChD,IAAA,EAAM,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC3B,IAAA,EAAM,IAAA,CAAK,MAAM,CAAA,CAAE,OAAA,EAAQ;AAAA,IAC3B,SAAA,EAAW,aAAa,YAAY,CAAA;AAAA,IACpC,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,WAAA,CAAY,qCAAqC,CAAA,CAAE,EAAA;AAAA,MACjD,KAAA,CAAM,KAAA;AAAA,MACN,KAAA,CAAM,QAAA;AAAA,MACN,KAAA,CAAM;AAAA;AACR;AAEJ;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,cAAc;AACzD,CAAC;AAOM,IAAM,aAAA,GAAgB;AAAA,EAC3B,aAAA;AAAA,EACA,aAAA;AAAA,EACA,yBAAA,EAA2B;AAC7B","file":"sqlite.js","sourcesContent":["/**\n * Drizzle schema for @dimah-s3/db on SQLite. Copy this file into your app\n * (`db/schema.ts`) to own the tables and add columns. Keep the table names,\n * the column names, and the `dimahS3Tables` keys: the adapter finds the\n * tables by those keys. A column you add must be nullable or have a default.\n * The plugin does not read or write it.\n *\n * Import `dimahS3Tables` from `@dimah-s3/db/drizzle/sqlite` when the tables\n * stay as they are. `drizzle-kit` then follows that import, and a later push\n * drops a column that is not part of it.\n *\n * Timestamps are epoch milliseconds and sizes are integers, matching\n * `sql/sqlite.sql`. Requires `drizzle-orm` and `@paralleldrive/cuid2`.\n */\nimport { createId } from \"@paralleldrive/cuid2\";\nimport { sql } from \"drizzle-orm\";\nimport {\n index,\n integer,\n sqliteTable,\n text,\n uniqueIndex,\n} from \"drizzle-orm/sqlite-core\";\n\ntype StorageObjectStatus = \"pending\" | \"active\" | \"deleted\" | \"purging\";\n\nconst SCHEMA_VERSION = \"2.1.0\";\n\nfunction id() {\n return text(\"id\")\n .primaryKey()\n .$defaultFn(() => createId());\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(() => new Date());\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 folderId: text(\"folder_id\"),\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.folderId,\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 /** `\"\"` is the root. */\n parentId: text(\"parent_id\").notNull().default(\"\"),\n name: text(\"name\").notNull(),\n path: text(\"path\").notNull(),\n createdAt: timestampNow(\"created_at\"),\n updatedAt: timestampNow(\"updated_at\"),\n },\n (table) => [\n uniqueIndex(\"storage_folder_scope_path_uk\").on(table.scope, table.path),\n uniqueIndex(\"storage_folder_scope_parent_name_uk\").on(\n table.scope,\n table.parentId,\n table.name,\n ),\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(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/prisma/dimah-s3.prisma
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
// Prisma models for @dimah-s3/db schema 2.1.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` and `path`,
|
|
11
|
-
// `@db.DateTime(3)` to the timestamps, and index prefixes such as
|
|
12
|
-
// `@@unique([bucket, key(length: 512)])`. `parentId` is `""` at the root.
|
|
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
|
-
/// Folder that holds the object. `null` is the root.
|
|
25
|
-
folderId String? @map("folder_id")
|
|
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, folderId, 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
|
-
/// Id of the containing folder. `""` is the root.
|
|
64
|
-
parentId String @map("parent_id")
|
|
65
|
-
/// Last segment of `path`.
|
|
66
|
-
name String
|
|
67
|
-
/// Full folder path.
|
|
68
|
-
path String
|
|
69
|
-
createdAt DateTime @default(now()) @map("created_at")
|
|
70
|
-
updatedAt DateTime @default(now()) @map("updated_at")
|
|
71
|
-
|
|
72
|
-
@@unique([scope, path], map: "storage_folder_scope_path_uk")
|
|
73
|
-
@@unique([scope, parentId, name], map: "storage_folder_scope_parent_name_uk")
|
|
74
|
-
@@map("storage_folder")
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/// FumaDB settings. The adapter reads the schema version from the `version` row.
|
|
78
|
-
model private_dimah_s3_settings {
|
|
79
|
-
key String @id
|
|
80
|
-
value String @default("2.1.0")
|
|
81
|
-
}
|
package/sql/mysql.sql
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
-- @dimah-s3/db schema 2.1.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` and `path` are indexed by prefix: two values that
|
|
5
|
-
-- share their first 512 characters share an index entry, and the unique
|
|
6
|
-
-- keys treat them as equal. `parent_id` is `''` at the root.
|
|
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_id` varchar(255),
|
|
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_id`, `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
|
-
`parent_id` varchar(255) NOT NULL DEFAULT '',
|
|
44
|
-
`name` varchar(255) NOT NULL,
|
|
45
|
-
`path` varchar(1024) NOT NULL,
|
|
46
|
-
`created_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
47
|
-
`updated_at` datetime(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
|
|
48
|
-
PRIMARY KEY (`id`),
|
|
49
|
-
UNIQUE KEY `storage_folder_scope_path_uk` (`scope`, `path`(512)),
|
|
50
|
-
UNIQUE KEY `storage_folder_scope_parent_name_uk` (`scope`, `parent_id`, `name`)
|
|
51
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
52
|
-
|
|
53
|
-
-- Schema version for the Kysely and Prisma adapters.
|
|
54
|
-
CREATE TABLE `private_dimah_s3_settings` (
|
|
55
|
-
`key` varchar(255) NOT NULL,
|
|
56
|
-
`value` text NOT NULL DEFAULT ('2.1.0'),
|
|
57
|
-
PRIMARY KEY (`key`)
|
|
58
|
-
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
|
|
59
|
-
|
|
60
|
-
INSERT INTO `private_dimah_s3_settings` (`key`, `value`) VALUES ('version', '2.1.0');
|
package/sql/pg.sql
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
-- @dimah-s3/db schema 2.1.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_id" 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_id", "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
|
-
"parent_id" text NOT NULL DEFAULT '',
|
|
39
|
-
"name" text NOT NULL,
|
|
40
|
-
"path" text NOT NULL,
|
|
41
|
-
"created_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
42
|
-
"updated_at" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
43
|
-
CONSTRAINT "storage_folder_scope_path_uk" UNIQUE ("scope", "path"),
|
|
44
|
-
CONSTRAINT "storage_folder_scope_parent_name_uk" UNIQUE ("scope", "parent_id", "name")
|
|
45
|
-
);
|
|
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.1.0'
|
|
51
|
-
);
|
|
52
|
-
|
|
53
|
-
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.1.0');
|
package/sql/sqlite.sql
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
-- @dimah-s3/db schema 2.1.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_id" 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_id", "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
|
-
"parent_id" text NOT NULL DEFAULT '',
|
|
40
|
-
"name" text NOT NULL,
|
|
41
|
-
"path" text NOT NULL,
|
|
42
|
-
"created_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000),
|
|
43
|
-
"updated_at" integer NOT NULL DEFAULT (strftime('%s', 'now') * 1000)
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
CREATE UNIQUE INDEX "storage_folder_scope_path_uk" ON "storage_folder" ("scope", "path");
|
|
47
|
-
CREATE UNIQUE INDEX "storage_folder_scope_parent_name_uk" ON "storage_folder" ("scope", "parent_id", "name");
|
|
48
|
-
|
|
49
|
-
-- Schema version for the Kysely and Prisma adapters.
|
|
50
|
-
CREATE TABLE "private_dimah_s3_settings" (
|
|
51
|
-
"key" text PRIMARY KEY NOT NULL,
|
|
52
|
-
"value" text NOT NULL DEFAULT '2.1.0'
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
INSERT INTO "private_dimah_s3_settings" ("key", "value") VALUES ('version', '2.1.0');
|
package/src/drizzle/mysql.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Drizzle schema for @dimah-s3/db on MySQL 8. Copy this file into your app
|
|
3
|
-
* (`db/schema.ts`) to own the tables and add columns. Keep the table names,
|
|
4
|
-
* the column names, and the `dimahS3Tables` keys: the adapter finds the
|
|
5
|
-
* tables by those keys. A column you add must be nullable or have a default.
|
|
6
|
-
* The plugin does not read or write it.
|
|
7
|
-
*
|
|
8
|
-
* Import `dimahS3Tables` from `@dimah-s3/db/drizzle/mysql` when the tables
|
|
9
|
-
* stay as they are. `drizzle-kit` then follows that import, and a later push
|
|
10
|
-
* drops a column that is not part of it.
|
|
11
|
-
*
|
|
12
|
-
* Columns, collations and indexes match `sql/mysql.sql`, including the
|
|
13
|
-
* prefix indexes on `key`, `folder`, `path` and `parent`. Keys, folders and
|
|
14
|
-
* scopes compare byte for byte (`utf8mb4_bin`), and file names
|
|
15
|
-
* case-insensitively (`utf8mb4_unicode_ci`). Requires `drizzle-orm` and
|
|
16
|
-
* `@paralleldrive/cuid2`.
|
|
17
|
-
*/
|
|
18
|
-
import { createId } from "@paralleldrive/cuid2";
|
|
19
|
-
import { sql } from "drizzle-orm";
|
|
20
|
-
import {
|
|
21
|
-
bigint,
|
|
22
|
-
datetime,
|
|
23
|
-
index,
|
|
24
|
-
json,
|
|
25
|
-
mysqlTable,
|
|
26
|
-
text,
|
|
27
|
-
uniqueIndex,
|
|
28
|
-
varchar,
|
|
29
|
-
type MySqlColumn,
|
|
30
|
-
} from "drizzle-orm/mysql-core";
|
|
31
|
-
|
|
32
|
-
type StorageObjectStatus = "pending" | "active" | "deleted" | "purging";
|
|
33
|
-
|
|
34
|
-
const SCHEMA_VERSION = "2.1.0";
|
|
35
|
-
|
|
36
|
-
/** Collation of every text column but `filename`: byte for byte. */
|
|
37
|
-
const BINARY = "utf8mb4_bin";
|
|
38
|
-
|
|
39
|
-
function id() {
|
|
40
|
-
return string("id")
|
|
41
|
-
.primaryKey()
|
|
42
|
-
.$defaultFn(() => createId());
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function string(name: string, length = 255) {
|
|
46
|
-
return varchar(name, { length }).collate(BINARY);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function timestamp(name: string) {
|
|
50
|
-
return datetime(name, { mode: "date", fsp: 3 });
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
function timestampNow(name: string) {
|
|
54
|
-
return timestamp(name)
|
|
55
|
-
.notNull()
|
|
56
|
-
.default(sql`CURRENT_TIMESTAMP(3)`)
|
|
57
|
-
.$defaultFn(() => new Date());
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
function byteCount(name: string) {
|
|
61
|
-
return bigint(name, { mode: "number" });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/** An index on the first `length` characters of a long column. */
|
|
65
|
-
function prefix(column: MySqlColumn, length: number) {
|
|
66
|
-
return sql`${column}(${sql.raw(String(length))})`;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** The `storage_object` table: one row per tracked object. */
|
|
70
|
-
export const storageObject = mysqlTable(
|
|
71
|
-
"storage_object",
|
|
72
|
-
{
|
|
73
|
-
id: id(),
|
|
74
|
-
scope: string("scope").notNull(),
|
|
75
|
-
bucket: string("bucket").notNull(),
|
|
76
|
-
key: string("key", 1024).notNull(),
|
|
77
|
-
route: string("route").notNull(),
|
|
78
|
-
folderId: string("folder_id"),
|
|
79
|
-
filename: varchar("filename", { length: 255 })
|
|
80
|
-
.collate("utf8mb4_unicode_ci")
|
|
81
|
-
.notNull(),
|
|
82
|
-
contentType: string("content_type"),
|
|
83
|
-
size: byteCount("size"),
|
|
84
|
-
declaredSize: byteCount("declared_size"),
|
|
85
|
-
eTag: string("e_tag"),
|
|
86
|
-
status: string("status", 16).$type<StorageObjectStatus>().notNull(),
|
|
87
|
-
s3Metadata: json("s3_metadata").$type<Record<string, string>>(),
|
|
88
|
-
attributes: json("attributes"),
|
|
89
|
-
acl: string("acl"),
|
|
90
|
-
uploadId: text("upload_id").collate(BINARY),
|
|
91
|
-
uploadToken: string("upload_token", 64),
|
|
92
|
-
expiresAt: timestamp("expires_at"),
|
|
93
|
-
confirmedAt: timestamp("confirmed_at"),
|
|
94
|
-
createdAt: timestampNow("created_at"),
|
|
95
|
-
updatedAt: timestampNow("updated_at"),
|
|
96
|
-
deletedAt: timestamp("deleted_at"),
|
|
97
|
-
},
|
|
98
|
-
(table) => [
|
|
99
|
-
uniqueIndex("storage_object_bucket_key_uk").on(
|
|
100
|
-
table.bucket,
|
|
101
|
-
prefix(table.key, 512),
|
|
102
|
-
),
|
|
103
|
-
index("storage_object_scope_folder_idx").on(
|
|
104
|
-
table.scope,
|
|
105
|
-
table.status,
|
|
106
|
-
table.folderId,
|
|
107
|
-
table.createdAt,
|
|
108
|
-
),
|
|
109
|
-
index("storage_object_scope_updated_idx").on(
|
|
110
|
-
table.scope,
|
|
111
|
-
table.status,
|
|
112
|
-
table.updatedAt,
|
|
113
|
-
),
|
|
114
|
-
index("storage_object_scope_filename_idx").on(
|
|
115
|
-
table.scope,
|
|
116
|
-
table.status,
|
|
117
|
-
table.filename,
|
|
118
|
-
),
|
|
119
|
-
index("storage_object_scope_size_idx").on(
|
|
120
|
-
table.scope,
|
|
121
|
-
table.status,
|
|
122
|
-
table.size,
|
|
123
|
-
),
|
|
124
|
-
index("storage_object_status_expires_idx").on(
|
|
125
|
-
table.status,
|
|
126
|
-
table.expiresAt,
|
|
127
|
-
),
|
|
128
|
-
],
|
|
129
|
-
);
|
|
130
|
-
|
|
131
|
-
/** The `storage_folder` table: one row per folder, so empty folders list. */
|
|
132
|
-
export const storageFolder = mysqlTable(
|
|
133
|
-
"storage_folder",
|
|
134
|
-
{
|
|
135
|
-
id: id(),
|
|
136
|
-
scope: string("scope").notNull(),
|
|
137
|
-
/** `""` is the root. */
|
|
138
|
-
parentId: string("parent_id").notNull().default(""),
|
|
139
|
-
name: string("name").notNull(),
|
|
140
|
-
path: string("path", 1024).notNull(),
|
|
141
|
-
createdAt: timestampNow("created_at"),
|
|
142
|
-
updatedAt: timestampNow("updated_at"),
|
|
143
|
-
},
|
|
144
|
-
(table) => [
|
|
145
|
-
uniqueIndex("storage_folder_scope_path_uk").on(
|
|
146
|
-
table.scope,
|
|
147
|
-
prefix(table.path, 512),
|
|
148
|
-
),
|
|
149
|
-
uniqueIndex("storage_folder_scope_parent_name_uk").on(
|
|
150
|
-
table.scope,
|
|
151
|
-
table.parentId,
|
|
152
|
-
table.name,
|
|
153
|
-
),
|
|
154
|
-
],
|
|
155
|
-
);
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* The FumaDB settings table. The Drizzle adapter reads the schema version
|
|
159
|
-
* from the default of its `version` column, which is stored as `value`.
|
|
160
|
-
*/
|
|
161
|
-
export const dimahS3Settings = mysqlTable("private_dimah_s3_settings", {
|
|
162
|
-
key: string("key").primaryKey(),
|
|
163
|
-
version: text("value").collate(BINARY).notNull().default(SCHEMA_VERSION),
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Every @dimah-s3/db table. Spread it into your Drizzle schema and keep its
|
|
168
|
-
* keys, because the FumaDB Drizzle adapter finds tables by them:
|
|
169
|
-
* `drizzle({ client, relations: defineRelations({ ...dimahS3Tables }) })`.
|
|
170
|
-
*/
|
|
171
|
-
export const dimahS3Tables = {
|
|
172
|
-
storageObject,
|
|
173
|
-
storageFolder,
|
|
174
|
-
private_dimah_s3_settings: dimahS3Settings,
|
|
175
|
-
};
|