Skip to content

Commit

Permalink
fix: db migration not working (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
Meierschlumpf authored Oct 18, 2024
1 parent 59e5c03 commit 5b23f7d
Show file tree
Hide file tree
Showing 4 changed files with 294 additions and 138 deletions.
12 changes: 6 additions & 6 deletions drizzle/migrate/migrate.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// This file is used to migrate the database to the current version
// It is run when the docker container starts
import Database from 'better-sqlite3';
import dotenv from 'dotenv';
import { drizzle } from 'drizzle-orm/better-sqlite3';
import { migrate } from 'drizzle-orm/better-sqlite3/migrator';
const Database = require('better-sqlite3');
const path = require('path');
const dotenv = require('dotenv');
const { drizzle } = require('drizzle-orm/better-sqlite3');
const { migrate } = require('drizzle-orm/better-sqlite3/migrator');

const migrationsFolder = process.argv[2] ?? '../drizzle';

dotenv.config({ path: __dirname + '/../.env' });

dotenv.config({ path: path.join(__dirname, '/../.env') });
const sqlite = new Database(process.env.DATABASE_URL!.replace('file:', ''));

const db = drizzle(sqlite);
Expand Down
4 changes: 2 additions & 2 deletions drizzle/migrate/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
"license": "MIT",
"description": "This package.json is used for the migration script the dependencies are only installed within the Dockerfile.",
"scripts": {
"db:migrate": "ts-node ./migrate.ts"
"db:migrate": "tsx ./migrate.ts"
},
"dependencies": {
"@types/better-sqlite3": "^7.6.7",
"better-sqlite3": "8.6.0",
"drizzle-orm": "^0.28.6",
"dotenv": "^16.3.1",
"ts-node": "^10.9.1",
"tsx": "4.19.1",
"typescript": "^5.2.2"
}
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "homarr",
"version": "0.15.5",
"version": "0.15.6",
"description": "Homarr - A homepage for your server.",
"license": "MIT",
"repository": {
Expand All @@ -25,7 +25,7 @@
"test:coverage": "SKIP_ENV_VALIDATION=1 vitest run --coverage",
"docker:build": "turbo build && docker build . -t homarr:local-dev",
"docker:start": "docker run -p 7575:7575 --name homarr-development homarr:local-dev",
"db:migrate": "dotenv ts-node drizzle/migrate/migrate.ts ./drizzle"
"db:migrate": "dotenv tsx drizzle/migrate/migrate.ts ./drizzle"
},
"dependencies": {
"@ctrl/deluge": "^4.1.0",
Expand Down Expand Up @@ -151,7 +151,7 @@
"node-mocks-http": "^1.12.2",
"prettier": "^3.0.0",
"sass": "^1.56.1",
"ts-node": "latest",
"tsx": "4.19.1",
"turbo": "^1.10.12",
"typescript": "5.1.6",
"video.js": "^8.0.3",
Expand Down
Loading

0 comments on commit 5b23f7d

Please sign in to comment.