diff --git a/AGENT.md b/AGENT.md index 37e5e6d3..3ab13b78 100644 --- a/AGENT.md +++ b/AGENT.md @@ -11,6 +11,7 @@ - `cargo check --manifest-path backend/Cargo.toml` - Check backend - `cargo test --manifest-path backend/Cargo.toml` - Run backend tests - `cd frontend && npm test` - Run frontend tests (if configured) +- `npm run prepare-db` - Solves compile issues related to SQLX macros ## Architecture diff --git a/backend/.sqlx/query-0ac126dc834dc72fd7cbf4cc32ab23fec591cd48114905fadc59d15c38c9718c.json b/backend/.sqlx/query-0291d620d1e6c461b135c62e08621c41c22130a86d8664701bc390bc72fb4d4b.json similarity index 86% rename from backend/.sqlx/query-0ac126dc834dc72fd7cbf4cc32ab23fec591cd48114905fadc59d15c38c9718c.json rename to backend/.sqlx/query-0291d620d1e6c461b135c62e08621c41c22130a86d8664701bc390bc72fb4d4b.json index 526e1e44..32e1ce6e 100644 --- a/backend/.sqlx/query-0ac126dc834dc72fd7cbf4cc32ab23fec591cd48114905fadc59d15c38c9718c.json +++ b/backend/.sqlx/query-0291d620d1e6c461b135c62e08621c41c22130a86d8664701bc390bc72fb4d4b.json @@ -1,6 +1,6 @@ { "db_name": "SQLite", - "query": "SELECT \n t.id as \"id!: Uuid\", \n t.project_id as \"project_id!: Uuid\", \n t.title, \n t.description, \n t.status as \"status!: TaskStatus\", \n t.created_at as \"created_at!: DateTime\", \n t.updated_at as \"updated_at!: DateTime\",\n CASE WHEN in_progress_attempts.task_id IS NOT NULL THEN true ELSE false END as \"has_in_progress_attempt!\"\n FROM tasks t\n LEFT JOIN (\n SELECT DISTINCT ta.task_id \n FROM task_attempts ta\n INNER JOIN (\n SELECT task_attempt_id, MAX(created_at) as latest_created_at\n FROM task_attempt_activities\n GROUP BY task_attempt_id\n ) latest_activity ON ta.id = latest_activity.task_attempt_id\n INNER JOIN task_attempt_activities taa ON ta.id = taa.task_attempt_id \n AND taa.created_at = latest_activity.latest_created_at\n WHERE taa.status = 'inprogress'\n ) in_progress_attempts ON t.id = in_progress_attempts.task_id\n WHERE t.project_id = $1 \n ORDER BY t.created_at DESC", + "query": "SELECT \n t.id as \"id!: Uuid\", \n t.project_id as \"project_id!: Uuid\", \n t.title, \n t.description, \n t.status as \"status!: TaskStatus\", \n t.created_at as \"created_at!: DateTime\", \n t.updated_at as \"updated_at!: DateTime\",\n CASE WHEN in_progress_attempts.task_id IS NOT NULL THEN true ELSE false END as \"has_in_progress_attempt!\"\n FROM tasks t\n LEFT JOIN (\n SELECT DISTINCT ta.task_id \n FROM task_attempts ta\n INNER JOIN (\n SELECT task_attempt_id, MAX(created_at) as latest_created_at\n FROM task_attempt_activities\n GROUP BY task_attempt_id\n ) latest_activity ON ta.id = latest_activity.task_attempt_id\n INNER JOIN task_attempt_activities taa ON ta.id = taa.task_attempt_id \n AND taa.created_at = latest_activity.latest_created_at\n WHERE taa.status IN ('setuprunning', 'executorrunning')\n ) in_progress_attempts ON t.id = in_progress_attempts.task_id\n WHERE t.project_id = $1 \n ORDER BY t.created_at DESC", "describe": { "columns": [ { @@ -58,5 +58,5 @@ false ] }, - "hash": "0ac126dc834dc72fd7cbf4cc32ab23fec591cd48114905fadc59d15c38c9718c" + "hash": "0291d620d1e6c461b135c62e08621c41c22130a86d8664701bc390bc72fb4d4b" } diff --git a/package.json b/package.json index f278e537..3ab613cf 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "backend:build": "cargo build --release --manifest-path backend/Cargo.toml", "backend:run": "cargo run --manifest-path backend/Cargo.toml", "backend:test": "cargo test --lib", - "generate-types": "cd backend && cargo run --bin generate_types" + "generate-types": "cd backend && cargo run --bin generate_types", + "prepare-db": "./prepare_db.sh" }, "devDependencies": { "concurrently": "^8.2.2", diff --git a/prepare_db.sh b/prepare_db.sh new file mode 100755 index 00000000..c9ae1757 --- /dev/null +++ b/prepare_db.sh @@ -0,0 +1,7 @@ + +cd backend +touch prepare_db.sqlite +prepare_db_path=$(realpath prepare_db.sqlite) +DATABASE_URL=sqlite:$prepare_db_path cargo sqlx migrate run +DATABASE_URL=sqlite:$prepare_db_path cargo sqlx prepare +rm prepare_db.sqlite \ No newline at end of file