update db schema + populate allUser
This commit is contained in:
80
drizzle/0000_tired_impossible_man.sql
Normal file
80
drizzle/0000_tired_impossible_man.sql
Normal file
@@ -0,0 +1,80 @@
|
||||
CREATE TABLE `groups` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `image_to_user` (
|
||||
`user_id` integer PRIMARY KEY NOT NULL,
|
||||
`image_name` text NOT NULL,
|
||||
`created_on` integer DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `opinions` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`type` text DEFAULT '5Choice' NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `provinces` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `users` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`firstName` text NOT NULL,
|
||||
`lastName` text NOT NULL,
|
||||
`registerno` text,
|
||||
`title` text NOT NULL,
|
||||
`cid` text(13) NOT NULL,
|
||||
`age` integer NOT NULL,
|
||||
`phone` text NOT NULL,
|
||||
`public_phone` text,
|
||||
`facebook` text,
|
||||
`twitter` text,
|
||||
`tiktok` text,
|
||||
`other_social` text,
|
||||
`image` text,
|
||||
`email` text,
|
||||
`job` text NOT NULL,
|
||||
`education` text NOT NULL,
|
||||
`vision` text,
|
||||
`reason` text,
|
||||
`group_id` integer NOT NULL,
|
||||
`zone_id` integer NOT NULL,
|
||||
`verified` integer DEFAULT false NOT NULL,
|
||||
FOREIGN KEY (`group_id`) REFERENCES `groups`(`id`) ON UPDATE no action ON DELETE no action,
|
||||
FOREIGN KEY (`zone_id`) REFERENCES `zones`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `user_opinions` (
|
||||
`user_id` integer NOT NULL,
|
||||
`opinion_id` integer NOT NULL,
|
||||
`choice` text DEFAULT 'ignore',
|
||||
PRIMARY KEY(`opinion_id`, `user_id`),
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE no action,
|
||||
FOREIGN KEY (`opinion_id`) REFERENCES `opinions`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `user_to_selection` (
|
||||
`user_id` integer,
|
||||
`target_id` integer,
|
||||
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
|
||||
FOREIGN KEY (`target_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE `zones` (
|
||||
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
||||
`name` text NOT NULL,
|
||||
`province_id` integer NOT NULL,
|
||||
`total` integer DEFAULT 0 NOT NULL,
|
||||
FOREIGN KEY (`province_id`) REFERENCES `provinces`(`id`) ON UPDATE no action ON DELETE no action
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `groups_name_unique` ON `groups` (`name`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `opinions_name_unique` ON `opinions` (`name`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `provinces_name_unique` ON `provinces` (`name`);--> statement-breakpoint
|
||||
CREATE INDEX `phone_idx` ON `users` (`phone`);--> statement-breakpoint
|
||||
CREATE INDEX `image_idx` ON `users` (`image`);--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX `zones_name_province_id_unique` ON `zones` (`name`,`province_id`);
|
||||
Reference in New Issue
Block a user