diff --git a/playgrounds/app/migrations/0002_dizzy_timeslip.sql b/playgrounds/app/migrations/0002_dizzy_timeslip.sql new file mode 100644 index 0000000..56424d4 --- /dev/null +++ b/playgrounds/app/migrations/0002_dizzy_timeslip.sql @@ -0,0 +1,9 @@ +DROP INDEX IF EXISTS "users_table_email_unique";--> statement-breakpoint +DROP INDEX IF EXISTS "users_table_githubId_unique";--> statement-breakpoint +DROP INDEX IF EXISTS "users_table_githubUsername_unique";--> statement-breakpoint +DROP INDEX IF EXISTS "users_table_githubAvatarUrl_unique";--> statement-breakpoint +ALTER TABLE `snippets_table` ALTER COLUMN "shadowEnabled" TO "shadowEnabled" integer NOT NULL DEFAULT true;--> statement-breakpoint +CREATE UNIQUE INDEX `users_table_email_unique` ON `users_table` (`email`);--> statement-breakpoint +CREATE UNIQUE INDEX `users_table_githubId_unique` ON `users_table` (`githubId`);--> statement-breakpoint +CREATE UNIQUE INDEX `users_table_githubUsername_unique` ON `users_table` (`githubUsername`);--> statement-breakpoint +CREATE UNIQUE INDEX `users_table_githubAvatarUrl_unique` ON `users_table` (`githubAvatarUrl`); \ No newline at end of file diff --git a/playgrounds/app/migrations/meta/0002_snapshot.json b/playgrounds/app/migrations/meta/0002_snapshot.json new file mode 100644 index 0000000..a30d2bd --- /dev/null +++ b/playgrounds/app/migrations/meta/0002_snapshot.json @@ -0,0 +1,271 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "a9edb9c1-c4eb-4710-9ca9-48355da04fac", + "prevId": "a25d9e7c-46fc-4f89-b78f-a5382632f50d", + "tables": { + "snippets_table": { + "name": "snippets_table", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "userId": { + "name": "userId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "codeLeft": { + "name": "codeLeft", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "codeRight": { + "name": "codeRight", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "snippetWidth": { + "name": "snippetWidth", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 450 + }, + "yPadding": { + "name": "yPadding", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 42 + }, + "xPadding": { + "name": "xPadding", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 42 + }, + "shadowEnabled": { + "name": "shadowEnabled", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": true + }, + "shadowOffsetY": { + "name": "shadowOffsetY", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "shadowBlur": { + "name": "shadowBlur", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 10 + }, + "shadowColor": { + "name": "shadowColor", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'#000000'" + }, + "shadowOpacity": { + "name": "shadowOpacity", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0.6 + }, + "bgColor": { + "name": "bgColor", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'#ffffff'" + }, + "language": { + "name": "language", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'tsx'" + }, + "theme": { + "name": "theme", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'nord'" + } + }, + "indexes": {}, + "foreignKeys": { + "snippets_table_userId_users_table_id_fk": { + "name": "snippets_table_userId_users_table_id_fk", + "tableFrom": "snippets_table", + "tableTo": "users_table", + "columnsFrom": [ + "userId" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users_table": { + "name": "users_table", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "githubId": { + "name": "githubId", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "githubUsername": { + "name": "githubUsername", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "githubAvatarUrl": { + "name": "githubAvatarUrl", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "createdAt": { + "name": "createdAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "updatedAt": { + "name": "updatedAt", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + } + }, + "indexes": { + "users_table_email_unique": { + "name": "users_table_email_unique", + "columns": [ + "email" + ], + "isUnique": true + }, + "users_table_githubId_unique": { + "name": "users_table_githubId_unique", + "columns": [ + "githubId" + ], + "isUnique": true + }, + "users_table_githubUsername_unique": { + "name": "users_table_githubUsername_unique", + "columns": [ + "githubUsername" + ], + "isUnique": true + }, + "users_table_githubAvatarUrl_unique": { + "name": "users_table_githubAvatarUrl_unique", + "columns": [ + "githubAvatarUrl" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/playgrounds/app/migrations/meta/_journal.json b/playgrounds/app/migrations/meta/_journal.json index ccb1938..5a453f1 100644 --- a/playgrounds/app/migrations/meta/_journal.json +++ b/playgrounds/app/migrations/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1729646676735, "tag": "0001_burly_alice", "breakpoints": true + }, + { + "idx": 2, + "version": "6", + "when": 1729650906143, + "tag": "0002_dizzy_timeslip", + "breakpoints": true } ] } \ No newline at end of file diff --git a/playgrounds/app/src/db/schema.ts b/playgrounds/app/src/db/schema.ts index 9f89879..bcb5b55 100644 --- a/playgrounds/app/src/db/schema.ts +++ b/playgrounds/app/src/db/schema.ts @@ -23,8 +23,7 @@ export const snippetsTable = sqliteTable('snippets_table', { snippetWidth: int().notNull().default(450), yPadding: int().notNull().default(42), xPadding: int().notNull().default(42), - // sqlite doesn't support booleans - shadowEnabled: int().notNull().default(1), + shadowEnabled: int({ mode: 'boolean' }).notNull().default(true), shadowOffsetY: int().notNull().default(10), shadowBlur: int().notNull().default(10), shadowColor: text().notNull().default('#000000'), diff --git a/playgrounds/app/src/routes/api/snippets.ts b/playgrounds/app/src/routes/api/snippets.ts index 87817a7..ecec5ec 100644 --- a/playgrounds/app/src/routes/api/snippets.ts +++ b/playgrounds/app/src/routes/api/snippets.ts @@ -73,7 +73,7 @@ export async function POST(event: APIEvent) { snippetWidth, yPadding, xPadding, - shadowEnabled: shadowEnabled ? 1 : 0, + shadowEnabled, shadowOffsetY, shadowBlur, shadowColor, diff --git a/playgrounds/app/src/routes/api/snippets/[snippetId].ts b/playgrounds/app/src/routes/api/snippets/[snippetId].ts index 200004b..1875a4b 100644 --- a/playgrounds/app/src/routes/api/snippets/[snippetId].ts +++ b/playgrounds/app/src/routes/api/snippets/[snippetId].ts @@ -31,10 +31,7 @@ export async function GET(event: APIEvent) { } return new Response( - JSON.stringify({ - ...snippet, - shadowEnabled: snippet.shadowEnabled === 1, - }), + JSON.stringify(snippet), { status: 200, headers: { @@ -115,7 +112,7 @@ export async function PUT(event: APIEvent) { snippetWidth, yPadding, xPadding, - shadowEnabled: shadowEnabled ? 1 : 0, + shadowEnabled, shadowOffsetY, shadowBlur, shadowColor,