feat:multiple bezoekers
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
-- Migration: Replace wantsToPerform with registrationType + add isOver16 + drinkCardValue
|
||||
-- Migrate existing 'wants_to_perform' data to 'registration_type' before dropping
|
||||
|
||||
ALTER TABLE `registration` ADD `registration_type` text NOT NULL DEFAULT 'watcher';--> statement-breakpoint
|
||||
ALTER TABLE `registration` ADD `is_over_16` integer NOT NULL DEFAULT false;--> statement-breakpoint
|
||||
ALTER TABLE `registration` ADD `drink_card_value` integer DEFAULT 0;--> statement-breakpoint
|
||||
|
||||
-- Backfill registration_type from wants_to_perform
|
||||
UPDATE `registration` SET `registration_type` = 'performer' WHERE `wants_to_perform` = 1;--> statement-breakpoint
|
||||
UPDATE `registration` SET `registration_type` = 'watcher' WHERE `wants_to_perform` = 0;--> statement-breakpoint
|
||||
|
||||
-- Backfill drink_card_value for watchers
|
||||
UPDATE `registration` SET `drink_card_value` = 5 WHERE `wants_to_perform` = 0;--> statement-breakpoint
|
||||
|
||||
-- Create index on registration_type
|
||||
CREATE INDEX `registration_registrationType_idx` ON `registration` (`registration_type`);--> statement-breakpoint
|
||||
|
||||
-- Drop old wants_to_perform column (SQLite requires recreating the table)
|
||||
-- SQLite doesn't support DROP COLUMN directly in older versions, but Turso/libSQL does
|
||||
ALTER TABLE `registration` DROP COLUMN `wants_to_perform`;
|
||||
2
packages/db/src/migrations/0003_add_guests.sql
Normal file
2
packages/db/src/migrations/0003_add_guests.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
-- Migration: Add guests column (JSON text) to registration table
|
||||
ALTER TABLE `registration` ADD `guests` text;
|
||||
@@ -15,6 +15,13 @@
|
||||
"when": 1772480778632,
|
||||
"tag": "0001_third_stark_industries",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 2,
|
||||
"version": "6",
|
||||
"when": 1772520000000,
|
||||
"tag": "0002_registration_type_redesign",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -9,11 +9,19 @@ export const registration = sqliteTable(
|
||||
lastName: text("last_name").notNull(),
|
||||
email: text("email").notNull(),
|
||||
phone: text("phone"),
|
||||
wantsToPerform: integer("wants_to_perform", { mode: "boolean" })
|
||||
.notNull()
|
||||
.default(false),
|
||||
// registrationType: 'performer' | 'watcher'
|
||||
registrationType: text("registration_type").notNull().default("watcher"),
|
||||
// Performer-specific fields
|
||||
artForm: text("art_form"),
|
||||
experience: text("experience"),
|
||||
isOver16: integer("is_over_16", { mode: "boolean" })
|
||||
.notNull()
|
||||
.default(false),
|
||||
// Watcher-specific fields
|
||||
drinkCardValue: integer("drink_card_value").default(0),
|
||||
// Guests: JSON array of {firstName, lastName, email?, phone?} objects
|
||||
guests: text("guests"),
|
||||
// Shared
|
||||
extraQuestions: text("extra_questions"),
|
||||
managementToken: text("management_token").unique(),
|
||||
cancelledAt: integer("cancelled_at", { mode: "timestamp_ms" }),
|
||||
@@ -23,6 +31,7 @@ export const registration = sqliteTable(
|
||||
},
|
||||
(table) => [
|
||||
index("registration_email_idx").on(table.email),
|
||||
index("registration_registrationType_idx").on(table.registrationType),
|
||||
index("registration_artForm_idx").on(table.artForm),
|
||||
index("registration_createdAt_idx").on(table.createdAt),
|
||||
index("registration_managementToken_idx").on(table.managementToken),
|
||||
|
||||
Reference in New Issue
Block a user