diff --git a/.gitignore b/.gitignore
index 6001fd6..687afa6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,4 @@ build
data/
__pycache__/
mlruns
+AI-grep/
diff --git a/DEPLOYMENT.md b/DEPLOYMENT.md
index 15a055f..1b11b58 100644
--- a/DEPLOYMENT.md
+++ b/DEPLOYMENT.md
@@ -325,7 +325,7 @@ curl -X POST http://localhost:8001/predict \
The easiest way to deploy is with docker-compose:
```bash
-docker-compose up --build
+docker compose up --build
```
This will:
@@ -497,6 +497,23 @@ docker-compose up -d
docker-compose logs -f --tail=100
```
+**ML service healthcheck failing:**
+
+If the candle-annotator service fails to start with error "dependency failed to start: container candle_annotator-ml-service-1 is unhealthy", this is because the ml-service healthcheck requires `curl` to be installed in the container. This was fixed in commit `ecb2385` by adding curl to the ml-service Dockerfile.
+
+If you encounter this issue:
+1. Rebuild the ml-service: `docker compose build ml-service`
+2. Restart services: `docker compose up -d`
+
+**Migration errors during build:**
+
+If you see Drizzle migration errors like "table `annotations` already exists" during the Docker build process, this means the database file from a previous build is being included. This was fixed in commit by skipping migrations during the build phase. The migrations now only run at runtime.
+
+If you encounter this issue:
+1. Ensure `data/` is in `.dockerignore`
+2. Rebuild: `docker compose build --no-cache candle-annotator`
+3. Restart: `docker compose up -d`
+
### Update Procedure
To update the application:
diff --git a/next-env.d.ts b/next-env.d.ts
index c4b7818..9edff1c 100644
--- a/next-env.d.ts
+++ b/next-env.d.ts
@@ -1,6 +1,6 @@
///
///
-import "./.next/dev/types/routes.d.ts";
+import "./.next/types/routes.d.ts";
// NOTE: This file should not be edited
// see https://nextjs.org/docs/app/api-reference/config/typescript for more information.
diff --git a/src/lib/db/index.ts b/src/lib/db/index.ts
index 3370481..4a4400d 100644
--- a/src/lib/db/index.ts
+++ b/src/lib/db/index.ts
@@ -15,11 +15,24 @@ const dbPath = path.join(dataDir, 'candles.db');
const sqlite = new Database(dbPath);
export const db = drizzle(sqlite, { schema });
-// Run migrations on startup
-try {
- migrate(db, { migrationsFolder: path.join(process.cwd(), 'drizzle') });
- console.log('✅ Database migrations completed');
-} catch (error) {
- console.error('❌ Migration failed:', error);
- throw error;
+// Run migrations only in runtime (not during build)
+// Check if we're in build mode by looking for the NEXT_PHASE environment variable
+const isBuildTime = process.env.NEXT_PHASE === 'phase-production-build' || process.env.NEXT_PHASE === 'phase-development-build';
+
+if (!isBuildTime) {
+ try {
+ migrate(db, { migrationsFolder: path.join(process.cwd(), 'drizzle') });
+ console.log('✅ Database migrations completed');
+ } catch (error) {
+ // Check if error is about table already existing
+ const errorMessage = error instanceof Error ? error.message : String(error);
+ if (errorMessage.includes('already exists')) {
+ console.log('⚠️ Database tables already exist, skipping migrations');
+ } else {
+ console.error('❌ Migration failed:', error);
+ throw error;
+ }
+ }
+} else {
+ console.log('ℹ️ Skipping migrations during build phase');
}