From 4cc2625d29ae3a5f213caa1d48c97f29b63dfd6b Mon Sep 17 00:00:00 2001 From: Timo Clasen Date: Sun, 5 May 2024 20:59:37 +0200 Subject: [PATCH 1/4] Improve resources query --- src/data/resources/resources.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/data/resources/resources.ts b/src/data/resources/resources.ts index 819eff6c..f8676a5a 100644 --- a/src/data/resources/resources.ts +++ b/src/data/resources/resources.ts @@ -334,9 +334,12 @@ export const selectResources = async ( } resourcesQuery.where(() => { - const where: Array | undefined> = [ - inArray(resource.id, resourceIdsQuery), - ]; + const where: Array | undefined> = []; + + // Limit + if (limit) { + where.push(inArray(resource.id, resourceIdsQuery)); + } // Search if (filter.search) { From e091d44c21ac7cf80759fc67d0c886be46b74146 Mon Sep 17 00:00:00 2001 From: Timo Clasen Date: Sun, 5 May 2024 20:59:54 +0200 Subject: [PATCH 2/4] Make categoryId column not null --- src/components/ResourceCard/ResourceCard.tsx | 8 +++----- src/db/schema.ts | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/ResourceCard/ResourceCard.tsx b/src/components/ResourceCard/ResourceCard.tsx index b25ec504..f3f1efe3 100644 --- a/src/components/ResourceCard/ResourceCard.tsx +++ b/src/components/ResourceCard/ResourceCard.tsx @@ -218,11 +218,9 @@ export const ResourceCard = async ({ resource, details }: Props) => { }`} > {/* Category */} - {resource.category && ( - - {resource.category.name} - - )} + + {resource.category.name} + {/* Link */}
diff --git a/src/db/schema.ts b/src/db/schema.ts index de3ea6ab..944c91af 100644 --- a/src/db/schema.ts +++ b/src/db/schema.ts @@ -26,9 +26,9 @@ export const resource = sqliteTable( typeId: integer('type_id', { mode: 'number' }) .notNull() .references(() => type.id), - categoryId: integer('category_id', { mode: 'number' }).references( - () => category.id, - ), + categoryId: integer('category_id', { mode: 'number' }) + .notNull() + .references(() => category.id), shortDescription: text('short_description', { mode: 'text' }), description: text('description', { mode: 'text' }), details: text('details', { mode: 'text' }), From 7c67f11fafa14a477442b1bd3893c90f4f7eaa2e Mon Sep 17 00:00:00 2001 From: Timo Clasen Date: Sun, 5 May 2024 21:14:47 +0200 Subject: [PATCH 3/4] Update redirects --- next.config.mjs | 149 ++++++++++++++++++++--------------------- src/db/execute.ts | 6 +- src/lib/utils/utils.ts | 5 +- 3 files changed, 81 insertions(+), 79 deletions(-) diff --git a/next.config.mjs b/next.config.mjs index 144c6e59..2484c290 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -131,86 +131,31 @@ const redirects = [ destination: '/resources/jonathan-chapman', permanent: true, }, - { - source: '/resources/thoughtleader-20', - destination: '/resources/ron-wakkary', - permanent: true, - }, { source: '/resources/thoughtleader-21', destination: '/resources/hemant-taneja', permanent: true, }, - { - source: '/resources/thoughtleader-22', - destination: '/resources/kevin-maney', - permanent: true, - }, - { - source: '/resources/thoughtleader-23', - destination: '/resources/kenneth-chenault', - permanent: true, - }, { source: '/resources/thoughtleader-24', destination: '/resources/leyla-acaroglu', permanent: true, }, - { - source: '/resources/thoughtleader-25', - destination: '/resources/liza-kindred', - permanent: true, - }, { source: '/resources/thoughtleader-26', destination: '/resources/jane-fulton-suri', permanent: true, }, - { - source: '/resources/thoughtleader-27', - destination: '/resources/carey-jenkins', - permanent: true, - }, - { - source: '/resources/thoughtleader-28', - destination: '/resources/tim-jackson', - permanent: true, - }, { source: '/resources/thoughtleader-29', destination: '/resources/joe-toscano', permanent: true, }, - { - source: '/resources/thoughtleader-30', - destination: '/resources/david-wortmann', - permanent: true, - }, - { - source: '/resources/thoughtleader-31', - destination: '/resources/anthony-dunne', - permanent: true, - }, - { - source: '/resources/thoughtleader-32', - destination: '/resources/fiona-raby', - permanent: true, - }, - { - source: '/resources/thoughtleader-33', - destination: '/resources/simon-mundy', - permanent: true, - }, { source: '/resources/thoughtleader-34', destination: '/resources/bruce-mau', permanent: true, }, - { - source: '/resources/thoughtleader-35', - destination: '/resources/alita-joyce', - permanent: true, - }, { source: '/resources/thoughtleader-36', destination: '/resources/solitaire-townsend', @@ -266,11 +211,6 @@ const redirects = [ destination: '/resources/brent-toderian', permanent: true, }, - { - source: '/resources/thoughtleader-47', - destination: '/resources/sierra-robinson', - permanent: true, - }, { source: '/resources/thoughtleader-48', destination: '/resources/janine-benyus', @@ -368,7 +308,7 @@ const redirects = [ { source: '/resources/article-8', destination: - '/resources/life-centered-design--wie-design-mit-der-trendwende-vom-profit-zum-purpose-die-welt-retten-will', + '/resources/life-centered-design-wie-design-mit-der-trendwende-vom-profit-zum-purpose-die-welt-retten-will', permanent: true, }, { @@ -406,7 +346,7 @@ const redirects = [ { source: '/resources/article-15', destination: - '/resources/your-next-persona-will-be-non-human--tools-for-environment-centered-designers', + '/resources/your-next-persona-will-be-non-human-tools-for-environment-centered-designers', permanent: true, }, { @@ -441,7 +381,67 @@ const redirects = [ }, { source: '/resources/example-2', - destination: '/resources/rewe-green-farming--supermarkt-umgedacht', + destination: '/resources/rewe-green-farming-supermarkt-umgedacht', + permanent: true, + }, + { + source: '/resources/thoughtleader-20', + destination: '/resources/ron-wakkary', + permanent: true, + }, + { + source: '/resources/thoughtleader-22', + destination: '/resources/kevin-maney', + permanent: true, + }, + { + source: '/resources/thoughtleader-23', + destination: '/resources/kenneth-chenault', + permanent: true, + }, + { + source: '/resources/thoughtleader-25', + destination: '/resources/liza-kindred', + permanent: true, + }, + { + source: '/resources/thoughtleader-27', + destination: '/resources/carey-jenkins', + permanent: true, + }, + { + source: '/resources/thoughtleader-28', + destination: '/resources/tim-jackson', + permanent: true, + }, + { + source: '/resources/thoughtleader-30', + destination: '/resources/david-wortmann', + permanent: true, + }, + { + source: '/resources/thoughtleader-31', + destination: '/resources/anthony-dunne', + permanent: true, + }, + { + source: '/resources/thoughtleader-32', + destination: '/resources/fiona-raby', + permanent: true, + }, + { + source: '/resources/thoughtleader-33', + destination: '/resources/simon-mundy', + permanent: true, + }, + { + source: '/resources/thoughtleader-35', + destination: '/resources/alita-joyce', + permanent: true, + }, + { + source: '/resources/thoughtleader-47', + destination: '/resources/sierra-robinson', permanent: true, }, { @@ -470,7 +470,7 @@ const redirects = [ { source: '/resources/book-5', destination: - '/resources/world-wide-waste-how-digital-is-killing-our-planet--and-what-we-can-do-about-it-', + '/resources/world-wide-waste-how-digital-is-killing-our-planet-and-what-we-can-do-about-it-', permanent: true, }, { @@ -736,7 +736,7 @@ const redirects = [ }, { source: '/resources/community-16', - destination: '/resources/ecological-design-collective--community', + destination: '/resources/ecological-design-collective-community', permanent: true, }, { @@ -852,8 +852,7 @@ const redirects = [ }, { source: '/resources/podcastEpisode-20', - destination: - '/resources/the-future-is-life-centered---jane-fulton-suri-ideo', + destination: '/resources/the-future-is-life-centered-jane-fulton-suri-ideo', permanent: true, }, { @@ -927,7 +926,7 @@ const redirects = [ }, { source: '/resources/video-5', - destination: '/resources/life-centered-design-by-bruce-mau--bodw-2021', + destination: '/resources/life-centered-design-by-bruce-mau-bodw-2021', permanent: true, }, { @@ -943,7 +942,7 @@ const redirects = [ { source: '/resources/video-8', destination: - '/resources/beyond-sustainability-a-call-for-regeneration--sierra-robinson--tedxyouthseattle', + '/resources/beyond-sustainability-a-call-for-regeneration-sierra-robinson-tedxyouthseattle', permanent: true, }, { @@ -955,13 +954,13 @@ const redirects = [ { source: '/resources/video-10', destination: - '/resources/biomimicry-definition--examples-explained-with-drawings', + '/resources/biomimicry-definition-examples-explained-with-drawings', permanent: true, }, { source: '/resources/video-11', destination: - '/resources/circular-economy-definition--examples--sustainability-environment', + '/resources/circular-economy-definition-examples-sustainability-environment', permanent: true, }, { @@ -1013,7 +1012,7 @@ const redirects = [ { source: '/resources/video-21', destination: - '/resources/creating-a-bio-industrial-revolution--janine-benyus', + '/resources/creating-a-bio-industrial-revolution-janine-benyus', permanent: true, }, { @@ -1510,7 +1509,7 @@ const redirects = [ }, { source: '/resources/tool-43', - destination: '/resources/sux---the-sustainable-ux-design-toolkit', + destination: '/resources/sux-the-sustainable-ux-design-toolkit', permanent: true, }, { @@ -1739,7 +1738,7 @@ const redirects = [ }, { source: '/resources/directory-12', - destination: '/resources/sustainable--ethical-methods-library', + destination: '/resources/sustainable-ethical-methods-library', permanent: true, }, { @@ -1845,7 +1844,7 @@ const redirects = [ }, { source: '/resources/directory-14', - destination: '/resources/sux-network---resource-collection--event-calendar', + destination: '/resources/sux-network-resource-collection-event-calendar', permanent: true, }, { diff --git a/src/db/execute.ts b/src/db/execute.ts index 6c42d7e3..6942ed61 100644 --- a/src/db/execute.ts +++ b/src/db/execute.ts @@ -18,14 +18,14 @@ const main = async () => { const resources = await db.query.resource.findMany({ columns: { - id: true, + slug: true, oldSlug: true, }, }); - const redirects = resources.map(({ id, oldSlug }) => ({ + const redirects = resources.map(({ slug, oldSlug }) => ({ source: `/resources/${oldSlug}`, - destination: `/resources/${id}`, + destination: `/resources/${slug}`, permanent: true, })); diff --git a/src/lib/utils/utils.ts b/src/lib/utils/utils.ts index b4dadfc5..2dc910fd 100644 --- a/src/lib/utils/utils.ts +++ b/src/lib/utils/utils.ts @@ -100,9 +100,12 @@ export const sluggify = (text: string) => .replace(/ö/g, 'oe') .replace(/ü/g, 'ue') .replace(/ - /g, '-') + .replace(/ \— /g, '-') + .replace(/ \– /g, '-') + .replace(/ \| /g, '-') .replace(/: /g, '-') + .replace(/ & /g, '-') .replace(/ /g, '-') - .replace(/&/g, 'and') .replace(/[^\w-]+/g, ''); /** From 515a8996599a109f957eb911d6e3af242944a6de Mon Sep 17 00:00:00 2001 From: Timo Clasen Date: Sun, 5 May 2024 21:16:02 +0200 Subject: [PATCH 4/4] Add migration --- drizzle.config.ts | 1 + package.json | 1 + src/db/migrations/0000_massive_mac_gargan.sql | 85 +++ src/db/migrations/meta/0000_snapshot.json | 583 ++++++++++++++++++ src/db/migrations/meta/_journal.json | 13 + 5 files changed, 683 insertions(+) create mode 100644 src/db/migrations/0000_massive_mac_gargan.sql create mode 100644 src/db/migrations/meta/0000_snapshot.json create mode 100644 src/db/migrations/meta/_journal.json diff --git a/drizzle.config.ts b/drizzle.config.ts index cd252e82..510b3f81 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -5,6 +5,7 @@ const { TURSO_DATABASE_URL, TURSO_AUTH_TOKEN } = process.env; export default { schema: './src/db/schema.ts', + out: './src/db/migrations', driver: 'turso', dbCredentials: { url: TURSO_DATABASE_URL, diff --git a/package.json b/package.json index 373b1b69..da20ba6d 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "db:migrate": "tsx ./src/db/migrate.ts", "db:execute": "tsx ./src/db/execute.ts", "db:reset": "rm ./local.db && pnpm db:push && pnpm db:seed", + "db:generate": "drizzle-kit generate:sqlite", "ui:add": "pnpm dlx shadcn-ui@latest add", "ui:diff": "pnpm dlx shadcn-ui diff", "prisma:generate": "prisma generate", diff --git a/src/db/migrations/0000_massive_mac_gargan.sql b/src/db/migrations/0000_massive_mac_gargan.sql new file mode 100644 index 00000000..5b17580e --- /dev/null +++ b/src/db/migrations/0000_massive_mac_gargan.sql @@ -0,0 +1,85 @@ +CREATE TABLE `category` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `name` text(256) NOT NULL, + `created_at` integer DEFAULT (unixepoch()) NOT NULL +); +--> statement-breakpoint +CREATE TABLE `comment` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `created_at` integer DEFAULT (unixepoch()) NOT NULL, + `user_id` text(256) NOT NULL, + `resource_id` integer NOT NULL, + `text` text NOT NULL, + FOREIGN KEY (`resource_id`) REFERENCES `resource`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `like` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `created_at` integer DEFAULT (unixepoch()) NOT NULL, + `user_id` text(256) NOT NULL, + `resource_id` integer NOT NULL, + FOREIGN KEY (`resource_id`) REFERENCES `resource`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `resource` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `created_at` integer DEFAULT (unixepoch()) NOT NULL, + `name` text(256) NOT NULL, + `slug` text(256) NOT NULL, + `suggestion` integer DEFAULT false NOT NULL, + `link` text(256) NOT NULL, + `type_id` integer NOT NULL, + `category_id` integer NOT NULL, + `short_description` text, + `description` text, + `details` text, + `note` text, + `date` integer, + `date_plain` text(256), + `related_resources_plain` text(256), + `anonymous_likes_count` integer DEFAULT 0 NOT NULL, + `old_slug` text(256), + FOREIGN KEY (`type_id`) REFERENCES `type`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`category_id`) REFERENCES `category`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `resource_to_related_resource` ( + `resource_id` integer NOT NULL, + `related_resource_id` integer NOT NULL, + PRIMARY KEY(`related_resource_id`, `resource_id`), + FOREIGN KEY (`resource_id`) REFERENCES `resource`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`related_resource_id`) REFERENCES `resource`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `resource_to_topic` ( + `resource_id` integer NOT NULL, + `topic_id` integer NOT NULL, + PRIMARY KEY(`resource_id`, `topic_id`), + FOREIGN KEY (`resource_id`) REFERENCES `resource`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`topic_id`) REFERENCES `topic`(`id`) ON UPDATE no action ON DELETE no action +); +--> statement-breakpoint +CREATE TABLE `topic` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `name` text(256) NOT NULL, + `created_at` integer DEFAULT (unixepoch()) NOT NULL +); +--> statement-breakpoint +CREATE TABLE `type` ( + `id` integer PRIMARY KEY AUTOINCREMENT NOT NULL, + `name` text(256) NOT NULL, + `created_at` integer DEFAULT (unixepoch()) NOT NULL +); +--> statement-breakpoint +CREATE UNIQUE INDEX `category_name_unique` ON `category` (`name`);--> statement-breakpoint +CREATE INDEX `user_id_idx` ON `comment` (`user_id`);--> statement-breakpoint +CREATE INDEX `resource_idx` ON `comment` (`resource_id`);--> statement-breakpoint +CREATE UNIQUE INDEX `like_resource_id_user_id_unique` ON `like` (`resource_id`,`user_id`);--> statement-breakpoint +CREATE UNIQUE INDEX `resource_slug_unique` ON `resource` (`slug`);--> statement-breakpoint +CREATE INDEX `created_at_idx` ON `resource` (`created_at`);--> statement-breakpoint +CREATE INDEX `name_idx` ON `resource` (`name`);--> statement-breakpoint +CREATE INDEX `type_idx` ON `resource` (`type_id`);--> statement-breakpoint +CREATE INDEX `category_idx` ON `resource` (`category_id`);--> statement-breakpoint +CREATE INDEX `anonymous_likes_count_idx` ON `resource` (`anonymous_likes_count`);--> statement-breakpoint +CREATE UNIQUE INDEX `topic_name_unique` ON `topic` (`name`);--> statement-breakpoint +CREATE UNIQUE INDEX `type_name_unique` ON `type` (`name`); \ No newline at end of file diff --git a/src/db/migrations/meta/0000_snapshot.json b/src/db/migrations/meta/0000_snapshot.json new file mode 100644 index 00000000..02195957 --- /dev/null +++ b/src/db/migrations/meta/0000_snapshot.json @@ -0,0 +1,583 @@ +{ + "version": "5", + "dialect": "sqlite", + "id": "5f9d61fc-0562-40fb-b611-24fe1fa59414", + "prevId": "00000000-0000-0000-0000-000000000000", + "tables": { + "category": { + "name": "category", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "category_name_unique": { + "name": "category_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "comment": { + "name": "comment", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "user_id": { + "name": "user_id", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resource_id": { + "name": "resource_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "user_id_idx": { + "name": "user_id_idx", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "resource_idx": { + "name": "resource_idx", + "columns": [ + "resource_id" + ], + "isUnique": false + } + }, + "foreignKeys": { + "comment_resource_id_resource_id_fk": { + "name": "comment_resource_id_resource_id_fk", + "tableFrom": "comment", + "tableTo": "resource", + "columnsFrom": [ + "resource_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "like": { + "name": "like", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "user_id": { + "name": "user_id", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "resource_id": { + "name": "resource_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "like_resource_id_user_id_unique": { + "name": "like_resource_id_user_id_unique", + "columns": [ + "resource_id", + "user_id" + ], + "isUnique": true + } + }, + "foreignKeys": { + "like_resource_id_resource_id_fk": { + "name": "like_resource_id_resource_id_fk", + "tableFrom": "like", + "tableTo": "resource", + "columnsFrom": [ + "resource_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "resource": { + "name": "resource", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "name": { + "name": "name", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "slug": { + "name": "slug", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "suggestion": { + "name": "suggestion", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "link": { + "name": "link", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type_id": { + "name": "type_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "category_id": { + "name": "category_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "short_description": { + "name": "short_description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "details": { + "name": "details", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "date_plain": { + "name": "date_plain", + "type": "text(256)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "related_resources_plain": { + "name": "related_resources_plain", + "type": "text(256)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "anonymous_likes_count": { + "name": "anonymous_likes_count", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "old_slug": { + "name": "old_slug", + "type": "text(256)", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": { + "resource_slug_unique": { + "name": "resource_slug_unique", + "columns": [ + "slug" + ], + "isUnique": true + }, + "created_at_idx": { + "name": "created_at_idx", + "columns": [ + "created_at" + ], + "isUnique": false + }, + "name_idx": { + "name": "name_idx", + "columns": [ + "name" + ], + "isUnique": false + }, + "type_idx": { + "name": "type_idx", + "columns": [ + "type_id" + ], + "isUnique": false + }, + "category_idx": { + "name": "category_idx", + "columns": [ + "category_id" + ], + "isUnique": false + }, + "anonymous_likes_count_idx": { + "name": "anonymous_likes_count_idx", + "columns": [ + "anonymous_likes_count" + ], + "isUnique": false + } + }, + "foreignKeys": { + "resource_type_id_type_id_fk": { + "name": "resource_type_id_type_id_fk", + "tableFrom": "resource", + "tableTo": "type", + "columnsFrom": [ + "type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "resource_category_id_category_id_fk": { + "name": "resource_category_id_category_id_fk", + "tableFrom": "resource", + "tableTo": "category", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "resource_to_related_resource": { + "name": "resource_to_related_resource", + "columns": { + "resource_id": { + "name": "resource_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "related_resource_id": { + "name": "related_resource_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "resource_to_related_resource_resource_id_resource_id_fk": { + "name": "resource_to_related_resource_resource_id_resource_id_fk", + "tableFrom": "resource_to_related_resource", + "tableTo": "resource", + "columnsFrom": [ + "resource_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "resource_to_related_resource_related_resource_id_resource_id_fk": { + "name": "resource_to_related_resource_related_resource_id_resource_id_fk", + "tableFrom": "resource_to_related_resource", + "tableTo": "resource", + "columnsFrom": [ + "related_resource_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "resource_to_related_resource_resource_id_related_resource_id_pk": { + "columns": [ + "related_resource_id", + "resource_id" + ], + "name": "resource_to_related_resource_resource_id_related_resource_id_pk" + } + }, + "uniqueConstraints": {} + }, + "resource_to_topic": { + "name": "resource_to_topic", + "columns": { + "resource_id": { + "name": "resource_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "topic_id": { + "name": "topic_id", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "resource_to_topic_resource_id_resource_id_fk": { + "name": "resource_to_topic_resource_id_resource_id_fk", + "tableFrom": "resource_to_topic", + "tableTo": "resource", + "columnsFrom": [ + "resource_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "resource_to_topic_topic_id_topic_id_fk": { + "name": "resource_to_topic_topic_id_topic_id_fk", + "tableFrom": "resource_to_topic", + "tableTo": "topic", + "columnsFrom": [ + "topic_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "resource_to_topic_resource_id_topic_id_pk": { + "columns": [ + "resource_id", + "topic_id" + ], + "name": "resource_to_topic_resource_id_topic_id_pk" + } + }, + "uniqueConstraints": {} + }, + "topic": { + "name": "topic", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "topic_name_unique": { + "name": "topic_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "type": { + "name": "type", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": true + }, + "name": { + "name": "name", + "type": "text(256)", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "type_name_unique": { + "name": "type_name_unique", + "columns": [ + "name" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/src/db/migrations/meta/_journal.json b/src/db/migrations/meta/_journal.json new file mode 100644 index 00000000..243b5fd1 --- /dev/null +++ b/src/db/migrations/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "5", + "dialect": "sqlite", + "entries": [ + { + "idx": 0, + "version": "5", + "when": 1714936549369, + "tag": "0000_massive_mac_gargan", + "breakpoints": true + } + ] +} \ No newline at end of file