Files
tipilan/migrations/0000_awesome_wendigo.sql

43 lines
1.6 KiB
SQL

CREATE TABLE `member` (
`id` text PRIMARY KEY NOT NULL,
`user_id` text NOT NULL,
`team_id` text,
`role` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`team_id`) REFERENCES `team`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_team_unique` ON `member` (`user_id`,`team_id`);--> statement-breakpoint
CREATE TABLE `team` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE `tournament_team` (
`id` text PRIMARY KEY NOT NULL,
`tournament_id` text NOT NULL,
`team_id` text NOT NULL,
`registration_date` integer NOT NULL,
FOREIGN KEY (`tournament_id`) REFERENCES `tournament`(`id`) ON UPDATE no action ON DELETE cascade,
FOREIGN KEY (`team_id`) REFERENCES `team`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE UNIQUE INDEX `tournament_team_unique` ON `tournament_team` (`tournament_id`,`team_id`);--> statement-breakpoint
CREATE TABLE `tournament` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE `user` (
`id` text PRIMARY KEY NOT NULL,
`email` text NOT NULL,
`steam_id` text,
`first_name` text NOT NULL,
`last_name` text NOT NULL,
`ticket_id` text,
`ticket_type` text
);
--> statement-breakpoint
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);--> statement-breakpoint
CREATE UNIQUE INDEX `user_steam_id_unique` ON `user` (`steam_id`);--> statement-breakpoint
CREATE UNIQUE INDEX `user_ticket_id_unique` ON `user` (`ticket_id`);