This commit is contained in:
s871077
2026-09-11 10:11:09 +08:00
parent e25c995560
commit 58587d19a8
25 changed files with 1643 additions and 54 deletions
+75
View File
@@ -0,0 +1,75 @@
-- Schema bootstrap for the containerized MySQL 8 pod (see Dockerfile.db).
-- Runs as /docker-entrypoint-initdb.d/01-schema.sql, i.e. ONLY on a first boot
-- against an empty datadir.
--
-- Body below is verbatim from:
-- prisma/prod/migrations/20260729000000_init/migration.sql
-- Do not edit that file — it stays the source of truth.
-- ---------------------------------------------------------------------------
-- Prisma migration bookkeeping.
-- The raw migration SQL creates no _prisma_migrations table, so a later
-- `npm run prod:migrate` would try to re-apply 20260729000000_init and fail
-- with "table already exists". Recording it as applied up front keeps future
-- migrations working against this volume.
-- ---------------------------------------------------------------------------
CREATE TABLE IF NOT EXISTS `_prisma_migrations` (
`id` VARCHAR(36) NOT NULL,
`checksum` VARCHAR(64) NOT NULL,
`finished_at` DATETIME(3) NULL,
`migration_name` VARCHAR(255) NOT NULL,
`logs` TEXT NULL,
`rolled_back_at` DATETIME(3) NULL,
`started_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`applied_steps_count` INT UNSIGNED NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
INSERT INTO `_prisma_migrations`
(`id`,`checksum`,`finished_at`,`migration_name`,`started_at`,`applied_steps_count`)
VALUES (UUID(),'bootstrapped-by-dockerfile-db',NOW(3),'20260729000000_init',NOW(3),1);
-- CreateTable
CREATE TABLE `CostItem` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`region` VARCHAR(191) NOT NULL,
`year` INTEGER NOT NULL,
`createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`updatedAt` DATETIME(3) NOT NULL,
INDEX `CostItem_region_year_idx`(`region`, `year`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `SubCostItem` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`subCost` DOUBLE NOT NULL,
`costItemId` INTEGER NOT NULL,
INDEX `SubCostItem_costItemId_idx`(`costItemId`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `TrendAiPercentage` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`region` VARCHAR(191) NOT NULL,
`year` INTEGER NOT NULL,
`percentage` DOUBLE NOT NULL,
UNIQUE INDEX `TrendAiPercentage_region_year_key`(`region`, `year`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `Year` (
`year` INTEGER NOT NULL,
PRIMARY KEY (`year`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `SubCostItem` ADD CONSTRAINT `SubCostItem_costItemId_fkey` FOREIGN KEY (`costItemId`) REFERENCES `CostItem`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;