Some checks failed
Deploy / deploy (push) Failing after 13s
Volume'deki app.db yalnızca ilk kurulumda seed'den kopyalanıyordu; sonraki deploy'larda şemaya eklenen kolonlar (son örnek: kredi_bitti_at, kredi_hatirlatma_gonderildi_at) prod'a hiç ulaşmıyor ve 'no such column' hatalarıyla kırılıyordu. - drizzle-kit generate ile baseline migration üretildi (drizzle/0000_baslangic) - scripts/db-goc.mjs: entrypoint'te server'dan önce koşan migration runner; drizzle migrator protokolünü birebir taklit eder (__drizzle_migrations, sha256, created_at=journal.when) ama yalnızca @libsql/client'a dayanır — drizzle-orm standalone imajda bundle'landığından paket olarak çözülemiyor - Benimseme: migration kaydı olmayan mevcut volume'lerde baseline additive uzlaştırılır (IF NOT EXISTS + snapshot'tan eksik kolon ALTER'ları) ve damgalanır; sonraki migration'lar normal akışla uygulanır - sema-guvence.ts kaldırıldı: elle DDL aynalama yerini migration'lara bıraktı - Yeni akış: şema değişikliğinde pnpm db:generate ile migration commit'lenir Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
132 lines
4.5 KiB
SQL
132 lines
4.5 KiB
SQL
CREATE TABLE `account` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`account_id` text NOT NULL,
|
|
`provider_id` text NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`access_token` text,
|
|
`refresh_token` text,
|
|
`id_token` text,
|
|
`access_token_expires_at` integer,
|
|
`refresh_token_expires_at` integer,
|
|
`scope` text,
|
|
`password` text,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `chat_messages` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`role` text NOT NULL,
|
|
`content` text NOT NULL,
|
|
`client_message_id` text,
|
|
`created_at` integer NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `chat_messages_client_message_id_unique` ON `chat_messages` (`client_message_id`);--> statement-breakpoint
|
|
CREATE INDEX `chat_user_created` ON `chat_messages` (`user_id`,`created_at`);--> statement-breakpoint
|
|
CREATE TABLE `credit_ledger` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`delta` integer NOT NULL,
|
|
`reason` text NOT NULL,
|
|
`ref_id` text,
|
|
`created_at` integer NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `ledger_reason_ref` ON `credit_ledger` (`reason`,`ref_id`);--> statement-breakpoint
|
|
CREATE INDEX `ledger_user` ON `credit_ledger` (`user_id`);--> statement-breakpoint
|
|
CREATE TABLE `orders` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`product` text NOT NULL,
|
|
`amount_kurus` integer NOT NULL,
|
|
`credits` integer NOT NULL,
|
|
`status` text DEFAULT 'pending' NOT NULL,
|
|
`iyzico_token` text,
|
|
`iyzico_payment_id` text,
|
|
`created_at` integer NOT NULL,
|
|
`paid_at` integer,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE INDEX `orders_user` ON `orders` (`user_id`);--> statement-breakpoint
|
|
CREATE TABLE `reports` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`params` text NOT NULL,
|
|
`result` text,
|
|
`revision_count` integer DEFAULT 0 NOT NULL,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `reports_user_id_unique` ON `reports` (`user_id`);--> statement-breakpoint
|
|
CREATE TABLE `saved_lists` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`user_id` text NOT NULL,
|
|
`items` text NOT NULL,
|
|
`profil` text,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `saved_lists_user_id_unique` ON `saved_lists` (`user_id`);--> statement-breakpoint
|
|
CREATE TABLE `session` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`expires_at` integer NOT NULL,
|
|
`token` text NOT NULL,
|
|
`ip_address` text,
|
|
`user_agent` text,
|
|
`user_id` text NOT NULL,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `session_token_unique` ON `session` (`token`);--> statement-breakpoint
|
|
CREATE TABLE `tadimlik_havuzu` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`kova_slug` text NOT NULL,
|
|
`tur` text NOT NULL,
|
|
`kategori_slug` text NOT NULL,
|
|
`program_id` text NOT NULL,
|
|
`dilim` text NOT NULL,
|
|
`gerekce` text NOT NULL,
|
|
`risk_notu` text NOT NULL,
|
|
`trend_ozeti` text NOT NULL,
|
|
`program` text NOT NULL,
|
|
`ornek_sira` integer NOT NULL,
|
|
`uretim_at` integer NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `tadimlik_anahtar` ON `tadimlik_havuzu` (`kova_slug`,`tur`,`kategori_slug`);--> statement-breakpoint
|
|
CREATE TABLE `user` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`name` text NOT NULL,
|
|
`email` text NOT NULL,
|
|
`email_verified` integer DEFAULT false NOT NULL,
|
|
`image` text,
|
|
`credit_balance` integer DEFAULT 0 NOT NULL,
|
|
`has_paket` integer DEFAULT false NOT NULL,
|
|
`kredi_bitti_at` integer,
|
|
`kredi_hatirlatma_gonderildi_at` integer,
|
|
`created_at` integer NOT NULL,
|
|
`updated_at` integer NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
|
|
CREATE TABLE `verification` (
|
|
`id` text PRIMARY KEY NOT NULL,
|
|
`identifier` text NOT NULL,
|
|
`value` text NOT NULL,
|
|
`expires_at` integer NOT NULL,
|
|
`created_at` integer,
|
|
`updated_at` integer
|
|
);
|