obsidian-visualiser/drizzle/0000_needy_rictor.sql

36 lines
1.2 KiB
SQL

CREATE TABLE `explorer_content` (
`path` text PRIMARY KEY NOT NULL,
`owner` integer NOT NULL,
`title` text NOT NULL,
`type` text NOT NULL,
`content` blob,
`navigable` integer DEFAULT true,
`private` integer DEFAULT false,
FOREIGN KEY (`owner`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `user_sessions` (
`id` integer NOT NULL,
`user_id` integer NOT NULL,
`timestamp` integer NOT NULL,
PRIMARY KEY(`id`, `user_id`),
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `users_data` (
`id` integer PRIMARY KEY NOT NULL,
`signin` integer NOT NULL,
FOREIGN KEY (`id`) REFERENCES `users`(`id`) ON UPDATE cascade ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `users` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`username` text NOT NULL,
`email` text NOT NULL,
`hash` text NOT NULL,
`state` integer DEFAULT 0 NOT NULL
);
--> statement-breakpoint
CREATE UNIQUE INDEX `users_username_unique` ON `users` (`username`);--> statement-breakpoint
CREATE UNIQUE INDEX `users_email_unique` ON `users` (`email`);--> statement-breakpoint
CREATE UNIQUE INDEX `users_hash_unique` ON `users` (`hash`);