From 555f6fbec38cbdfc8bce15171d5430734892acda Mon Sep 17 00:00:00 2001 From: Sanyam Jain Date: Fri, 28 Jun 2024 08:41:44 -0700 Subject: [PATCH] add deleted column --- migrations/0002_dapper_inertia.sql | 1 + migrations/meta/0002_snapshot.json | 343 +++++++++++++++++++++++++++++ migrations/meta/_journal.json | 7 + src/lib/db/turso.schema.ts | 1 + 4 files changed, 352 insertions(+) create mode 100644 migrations/0002_dapper_inertia.sql create mode 100644 migrations/meta/0002_snapshot.json diff --git a/migrations/0002_dapper_inertia.sql b/migrations/0002_dapper_inertia.sql new file mode 100644 index 0000000..bba5227 --- /dev/null +++ b/migrations/0002_dapper_inertia.sql @@ -0,0 +1 @@ +ALTER TABLE `card` ADD `deleted` integer DEFAULT false NOT NULL; \ No newline at end of file diff --git a/migrations/meta/0002_snapshot.json b/migrations/meta/0002_snapshot.json new file mode 100644 index 0000000..a7af0c6 --- /dev/null +++ b/migrations/meta/0002_snapshot.json @@ -0,0 +1,343 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "9fc13483-d39d-4945-a07a-47a468ecb826", + "prevId": "c7952378-d69a-40ba-b25b-d969973fa0ec", + "tables": { + "activity": { + "name": "activity", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "action": { + "name": "action", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "card_id": { + "name": "card_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": {}, + "foreignKeys": { + "activity_card_id_card_id_fk": { + "name": "activity_card_id_card_id_fk", + "tableFrom": "activity", + "tableTo": "card", + "columnsFrom": [ + "card_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "activity_user_id_auth_user_id_fk": { + "name": "activity_user_id_auth_user_id_fk", + "tableFrom": "activity", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "card": { + "name": "card", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "front": { + "name": "front", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "back": { + "name": "back", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "easiness": { + "name": "easiness", + "type": "real", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 2.5 + }, + "interval": { + "name": "interval", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 1 + }, + "repetitions": { + "name": "repetitions", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "next_practice": { + "name": "next_practice", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "deleted": { + "name": "deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": {}, + "foreignKeys": { + "card_user_id_auth_user_id_fk": { + "name": "card_user_id_auth_user_id_fk", + "tableFrom": "card", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user_session": { + "name": "user_session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": {}, + "foreignKeys": { + "user_session_user_id_auth_user_id_fk": { + "name": "user_session_user_id_auth_user_id_fk", + "tableFrom": "user_session", + "tableTo": "auth_user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "auth_user": { + "name": "auth_user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "given_name": { + "name": "given_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "family_name": { + "name": "family_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "picture": { + "name": "picture", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email_verified": { + "name": "email_verified", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "locale": { + "name": "locale", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "(unixepoch())" + } + }, + "indexes": { + "auth_user_email_unique": { + "name": "auth_user_email_unique", + "columns": [ + "email" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index e5117c5..41cd15c 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -15,6 +15,13 @@ "when": 1719460026182, "tag": "0001_plain_stingray", "breakpoints": true + }, + { + "idx": 2, + "version": "6", + "when": 1719589235789, + "tag": "0002_dapper_inertia", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/lib/db/turso.schema.ts b/src/lib/db/turso.schema.ts index ec43d8b..17aad42 100644 --- a/src/lib/db/turso.schema.ts +++ b/src/lib/db/turso.schema.ts @@ -39,6 +39,7 @@ export const cardTable = sqliteTable('card', { interval: integer('interval').notNull().default(1), repetitions: integer('repetitions').notNull().default(0), nextPractice: integer('next_practice', { mode: 'timestamp' }).default(sql`(unixepoch())`).notNull(), + deleted: integer('deleted', { mode: 'boolean' }).default(false).notNull(), createdAt: integer('created_at', { mode: 'timestamp' }).default(sql`(unixepoch())`).notNull(), updatedAt: integer('updated_at', { mode: 'timestamp' }).default(sql`(unixepoch())`).$onUpdate(() => new Date()).notNull(), })