You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
73 lines
3.3 KiB
73 lines
3.3 KiB
CREATE TABLE `posts` (
|
|
`id` integer PRIMARY KEY NOT NULL,
|
|
`user_id` integer NOT NULL,
|
|
`title` text NOT NULL,
|
|
`slug` text NOT NULL,
|
|
`body_markdown` text NOT NULL,
|
|
`excerpt` text NOT NULL,
|
|
`cover_url` text,
|
|
`tags_json` text DEFAULT '[]' NOT NULL,
|
|
`published_at` integer,
|
|
`visibility` text DEFAULT 'private' NOT NULL,
|
|
`share_token` text,
|
|
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
`updated_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `posts_user_id_slug_unique` ON `posts` (`user_id`,`slug`);--> statement-breakpoint
|
|
CREATE TABLE `timeline_events` (
|
|
`id` integer PRIMARY KEY NOT NULL,
|
|
`user_id` integer NOT NULL,
|
|
`occurred_on` integer NOT NULL,
|
|
`title` text NOT NULL,
|
|
`body_markdown` text,
|
|
`link_url` text,
|
|
`visibility` text DEFAULT 'private' NOT NULL,
|
|
`share_token` text,
|
|
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
`updated_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE `rss_feeds` (
|
|
`id` integer PRIMARY KEY NOT NULL,
|
|
`user_id` integer NOT NULL,
|
|
`feed_url` text NOT NULL,
|
|
`title` text,
|
|
`site_url` text,
|
|
`last_fetched_at` integer,
|
|
`last_error` text,
|
|
`poll_interval_minutes` integer,
|
|
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `rss_feeds_user_id_feed_url_unique` ON `rss_feeds` (`user_id`,`feed_url`);--> statement-breakpoint
|
|
CREATE TABLE `rss_items` (
|
|
`id` integer PRIMARY KEY NOT NULL,
|
|
`user_id` integer NOT NULL,
|
|
`feed_id` integer NOT NULL,
|
|
`guid` text,
|
|
`canonical_url` text NOT NULL,
|
|
`title` text,
|
|
`summary` text,
|
|
`content_snippet` text,
|
|
`author` text,
|
|
`published_at` integer,
|
|
`visibility` text DEFAULT 'private' NOT NULL,
|
|
`share_token` text,
|
|
`created_at` integer DEFAULT (cast((julianday('now') - 2440587.5)*86400000 as integer)) NOT NULL,
|
|
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade,
|
|
FOREIGN KEY (`feed_id`) REFERENCES `rss_feeds`(`id`) ON UPDATE no action ON DELETE cascade
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `rss_items_feed_id_guid_unique` ON `rss_items` (`feed_id`,`guid`) WHERE "rss_items"."guid" IS NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `role` text DEFAULT 'user' NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `status` text DEFAULT 'active' NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `public_slug` text;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `bio_markdown` text;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `bio_visibility` text DEFAULT 'private' NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `social_links_json` text DEFAULT '[]' NOT NULL;--> statement-breakpoint
|
|
ALTER TABLE `users` ADD `avatar_visibility` text DEFAULT 'private' NOT NULL;--> statement-breakpoint
|
|
CREATE UNIQUE INDEX `users_public_slug_unique` ON `users` (`public_slug`);
|