Initial commit

This commit is contained in:
2026-01-28 20:44:34 +08:00
commit 500e8b74a7
236 changed files with 29886 additions and 0 deletions

View File

@@ -0,0 +1,39 @@
-- MySQL 初始化语句
CREATE TABLE IF NOT EXISTS `file_batches` (
`id` varchar(36) PRIMARY KEY,
`pickup_code` varchar(255) UNIQUE NOT NULL,
`remark` longtext,
`expire_type` varchar(255),
`expire_at` datetime(3),
`max_downloads` bigint,
`download_count` bigint DEFAULT 0,
`status` varchar(255) DEFAULT 'active',
`type` varchar(255) DEFAULT 'file',
`content` longtext,
`created_at` datetime(3),
`updated_at` datetime(3),
`deleted_at` datetime(3),
KEY `idx_file_batches_deleted_at` (`deleted_at`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `file_items` (
`id` varchar(36) PRIMARY KEY,
`batch_id` varchar(36) NOT NULL,
`original_name` longtext,
`storage_path` longtext,
`size` bigint,
`mime_type` longtext,
`created_at` datetime(3),
KEY `idx_file_items_batch_id` (`batch_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS `api_tokens` (
`id` bigint unsigned AUTO_INCREMENT PRIMARY KEY,
`name` longtext,
`token_hash` varchar(255) UNIQUE NOT NULL,
`scope` longtext,
`expire_at` datetime(3),
`last_used_at` datetime(3),
`revoked` boolean DEFAULT false,
`created_at` datetime(3)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

View File

@@ -0,0 +1,40 @@
-- PostgreSQL 初始化语句
CREATE TABLE IF NOT EXISTS "file_batches" (
"id" varchar(36) PRIMARY KEY,
"pickup_code" varchar(255) UNIQUE NOT NULL,
"remark" text,
"expire_type" text,
"expire_at" timestamptz,
"max_downloads" bigint,
"download_count" bigint DEFAULT 0,
"status" text DEFAULT 'active',
"type" text DEFAULT 'file',
"content" text,
"created_at" timestamptz,
"updated_at" timestamptz,
"deleted_at" timestamptz
);
CREATE INDEX IF NOT EXISTS "idx_file_batches_deleted_at" ON "file_batches" ("deleted_at");
CREATE TABLE IF NOT EXISTS "file_items" (
"id" varchar(36) PRIMARY KEY,
"batch_id" varchar(36) NOT NULL,
"original_name" text,
"storage_path" text,
"size" bigint,
"mime_type" text,
"created_at" timestamptz,
CONSTRAINT "fk_file_batches_file_items" FOREIGN KEY ("batch_id") REFERENCES "file_batches"("id")
);
CREATE INDEX IF NOT EXISTS "idx_file_items_batch_id" ON "file_items" ("batch_id");
CREATE TABLE IF NOT EXISTS "api_tokens" (
"id" bigserial PRIMARY KEY,
"name" text,
"token_hash" varchar(255) UNIQUE NOT NULL,
"scope" text,
"expire_at" timestamptz,
"last_used_at" timestamptz,
"revoked" boolean DEFAULT false,
"created_at" timestamptz
);

View File

@@ -0,0 +1,40 @@
-- SQLite 初始化语句
CREATE TABLE IF NOT EXISTS `file_batches` (
`id` varchar(36) PRIMARY KEY,
`pickup_code` varchar(255) UNIQUE NOT NULL,
`remark` text,
`expire_type` text,
`expire_at` datetime,
`max_downloads` integer,
`download_count` integer DEFAULT 0,
`status` text DEFAULT 'active',
`type` text DEFAULT 'file',
`content` text,
`created_at` datetime,
`updated_at` datetime,
`deleted_at` datetime
);
CREATE INDEX IF NOT EXISTS `idx_file_batches_deleted_at` ON `file_batches` (`deleted_at`);
CREATE TABLE IF NOT EXISTS `file_items` (
`id` varchar(36) PRIMARY KEY,
`batch_id` varchar(36) NOT NULL,
`original_name` text,
`storage_path` text,
`size` bigint,
`mime_type` text,
`created_at` datetime,
FOREIGN KEY (`batch_id`) REFERENCES `file_batches`(`id`)
);
CREATE INDEX IF NOT EXISTS `idx_file_items_batch_id` ON `file_items` (`batch_id`);
CREATE TABLE IF NOT EXISTS `api_tokens` (
`id` integer PRIMARY KEY AUTOINCREMENT,
`name` text,
`token_hash` varchar(255) UNIQUE NOT NULL,
`scope` text,
`expire_at` datetime,
`last_used_at` datetime,
`revoked` boolean DEFAULT 0,
`created_at` datetime
);