Skip to content

Commit

Permalink
Added some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
d3rpp committed Aug 18, 2024
1 parent 19f99c3 commit 8ea3a98
Show file tree
Hide file tree
Showing 17 changed files with 410 additions and 304 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ vite.config.js.timestamp-*
vite.config.ts.timestamp-*

# SQLite Stuff
database.db
database.db*

# Devenv
.devenv*
Expand Down
Binary file modified bun.lockb
Binary file not shown.
18 changes: 16 additions & 2 deletions drizzle/0000_open_famine.sql → drizzle/0000_hot_sage.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,23 @@
CREATE TABLE `email_addresses` (
`email_id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`user_id` text(26),
`user_id` text(26) NOT NULL,
`email_address` text NOT NULL,
`is_verified` integer DEFAULT 0 NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `passwords` (
`user_id` text PRIMARY KEY NOT NULL,
`password_hash` text NOT NULL,
FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `public_assets` (
`file_name` text PRIMARY KEY NOT NULL,
`type` text NOT NULL,
`blob` blob NOT NULL
);
--> statement-breakpoint
CREATE TABLE `user_aliases` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`user_ref` text NOT NULL,
Expand All @@ -16,7 +28,9 @@ CREATE TABLE `user_aliases` (
CREATE TABLE `users` (
`id` text PRIMARY KEY NOT NULL,
`display_name` text,
`username` text NOT NULL
`username` text NOT NULL,
`profile_picture` text,
FOREIGN KEY (`profile_picture`) REFERENCES `public_assets`(`file_name`) ON UPDATE no action ON DELETE no action
);
--> statement-breakpoint
CREATE UNIQUE INDEX `email_addresses_email_address_unique` ON `email_addresses` (`email_address`);--> statement-breakpoint
Expand Down
5 changes: 0 additions & 5 deletions drizzle/0001_spicy_thena.sql

This file was deleted.

86 changes: 83 additions & 3 deletions drizzle/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": "6",
"dialect": "sqlite",
"id": "f3c55a7a-8bd7-451f-b5c2-ad2370a0829c",
"id": "86be13c9-c3e4-4d58-b449-58f12e9dfda3",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"email_addresses": {
Expand All @@ -18,7 +18,7 @@
"name": "user_id",
"type": "text(26)",
"primaryKey": false,
"notNull": false,
"notNull": true,
"autoincrement": false
},
"email_address": {
Expand Down Expand Up @@ -58,6 +58,69 @@
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"passwords": {
"name": "passwords",
"columns": {
"user_id": {
"name": "user_id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"password_hash": {
"name": "password_hash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"passwords_user_id_users_id_fk": {
"name": "passwords_user_id_users_id_fk",
"tableFrom": "passwords",
"tableTo": "users",
"columnsFrom": ["user_id"],
"columnsTo": ["id"],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"public_assets": {
"name": "public_assets",
"columns": {
"file_name": {
"name": "file_name",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"blob": {
"name": "blob",
"type": "blob",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user_aliases": {
"name": "user_aliases",
"columns": {
Expand Down Expand Up @@ -121,6 +184,13 @@
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"profile_picture": {
"name": "profile_picture",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {
Expand All @@ -130,7 +200,17 @@
"isUnique": true
}
},
"foreignKeys": {},
"foreignKeys": {
"users_profile_picture_public_assets_file_name_fk": {
"name": "users_profile_picture_public_assets_file_name_fk",
"tableFrom": "users",
"tableTo": "public_assets",
"columnsFrom": ["profile_picture"],
"columnsTo": ["file_name"],
"onDelete": "no action",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
Expand Down
177 changes: 0 additions & 177 deletions drizzle/meta/0001_snapshot.json

This file was deleted.

11 changes: 2 additions & 9 deletions drizzle/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1723761059597,
"tag": "0000_open_famine",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1723979465707,
"tag": "0001_spicy_thena",
"when": 1724016516054,
"tag": "0000_hot_sage",
"breakpoints": true
}
]
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"@sveltejs/vite-plugin-svelte": "^4.0.0-next.6",
"@types/eslint": "^9.6.0",
"autoprefixer": "^10.4.20",
"bun-types": "^1.1.22",
"bun-types": "^1.1.24",
"drizzle-kit": "^0.24.0",
"eslint": "^9.9.0",
"eslint-plugin-svelte": "^2.43.0",
Expand All @@ -28,13 +28,13 @@
"prettier": "^3.3.3",
"prettier-plugin-svelte": "^3.2.6",
"prettier-plugin-tailwindcss": "^0.6.6",
"svelte": "^5.0.0-next.218",
"svelte": "^5.0.0-next.225",
"svelte-adapter-bun": "^0.5.2",
"svelte-check": "^3.8.5",
"tailwindcss": "^3.4.9",
"tailwindcss": "^3.4.10",
"typescript": "^5.5.4",
"typescript-eslint": "^8.1.0",
"vite": "^5.4.0"
"vite": "^5.4.1"
},
"type": "module",
"trustedDependencies": [
Expand Down
2 changes: 1 addition & 1 deletion src/contrib/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { migrate } from "drizzle-orm/bun-sqlite/migrator";

import { DB } from "../lib/server/db";

await migrate(DB, { migrationsFolder: "./drizzle" });
migrate(DB, { migrationsFolder: "./drizzle" });
Loading

0 comments on commit 8ea3a98

Please sign in to comment.