Skip to content

Commit

Permalink
Add db migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mschuepbach committed Oct 14, 2023
1 parent 85c9f8c commit f9552a4
Show file tree
Hide file tree
Showing 4 changed files with 243 additions and 1 deletion.
11 changes: 11 additions & 0 deletions drizzle/0001_polite_the_fury.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
DO $$ BEGIN
CREATE TYPE "operation" AS ENUM('add', 'remove');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "history" (
"timestamp" timestamp with time zone DEFAULT now(),
"name" varchar(300),
"operation" "operation"
);
223 changes: 223 additions & 0 deletions drizzle/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
{
"version": "5",
"dialect": "pg",
"id": "66e5bc34-5d69-4b44-91a4-0ed6da483fdf",
"prevId": "4780e125-800d-40cd-850b-625bf52ebc1e",
"tables": {
"history": {
"name": "history",
"schema": "",
"columns": {
"timestamp": {
"name": "timestamp",
"type": "timestamp with time zone",
"primaryKey": false,
"notNull": false,
"default": "now()"
},
"name": {
"name": "name",
"type": "varchar(300)",
"primaryKey": false,
"notNull": false
},
"operation": {
"name": "operation",
"type": "operation",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"invite": {
"name": "invite",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(255)",
"primaryKey": true,
"notNull": true
},
"expires": {
"name": "expires",
"type": "bigint",
"primaryKey": false,
"notNull": true
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_key": {
"name": "user_key",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(255)",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "varchar(15)",
"primaryKey": false,
"notNull": true
},
"hashed_password": {
"name": "hashed_password",
"type": "varchar(255)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {
"user_key_user_id_auth_user_id_fk": {
"name": "user_key_user_id_auth_user_id_fk",
"tableFrom": "user_key",
"tableTo": "auth_user",
"columnsFrom": [
"user_id"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_session": {
"name": "user_session",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(128)",
"primaryKey": true,
"notNull": true
},
"user_id": {
"name": "user_id",
"type": "varchar(15)",
"primaryKey": false,
"notNull": true
},
"active_expires": {
"name": "active_expires",
"type": "bigint",
"primaryKey": false,
"notNull": true
},
"idle_expires": {
"name": "idle_expires",
"type": "bigint",
"primaryKey": false,
"notNull": true
}
},
"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": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"shopping_list": {
"name": "shopping_list",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(15)",
"primaryKey": true,
"notNull": true
},
"name": {
"name": "name",
"type": "varchar(300)",
"primaryKey": false,
"notNull": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"auth_user": {
"name": "auth_user",
"schema": "",
"columns": {
"id": {
"name": "id",
"type": "varchar(15)",
"primaryKey": true,
"notNull": true
},
"username": {
"name": "username",
"type": "varchar(31)",
"primaryKey": false,
"notNull": true
},
"isAdmin": {
"name": "isAdmin",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"default": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {
"auth_user_username_unique": {
"name": "auth_user_username_unique",
"nullsNotDistinct": false,
"columns": [
"username"
]
}
}
}
},
"enums": {
"operation": {
"name": "operation",
"values": {
"add": "add",
"remove": "remove"
}
}
},
"schemas": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
}
}
7 changes: 7 additions & 0 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
"when": 1693819891073,
"tag": "0000_curvy_timeslip",
"breakpoints": true
},
{
"idx": 1,
"version": "5",
"when": 1697299368656,
"tag": "0001_polite_the_fury",
"breakpoints": true
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"format": "prettier --write .",
"prodServer": "tsm ./prodServer.ts",
"db:push": "drizzle-kit push:pg",
"db:introspect": "drizzle-kit introspect:pg"
"db:introspect": "drizzle-kit introspect:pg",
"db:migration": "drizzle-kit generate:pg"
},
"devDependencies": {
"@sveltejs/adapter-node": "^1.3.1",
Expand Down

0 comments on commit f9552a4

Please sign in to comment.