Initial sqlite schema.
This commit is contained in:
parent
c2b7c12905
commit
3a7d28030d
7 changed files with 1305 additions and 14 deletions
2
backend/.gitignore
vendored
2
backend/.gitignore
vendored
|
|
@ -1 +1,3 @@
|
||||||
/target
|
/target
|
||||||
|
|
||||||
|
*.db
|
||||||
|
|
|
||||||
1287
backend/Cargo.lock
generated
1287
backend/Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
|
@ -5,6 +5,7 @@ edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.8.4"
|
axum = "0.8.4"
|
||||||
|
sqlx = "0.8.6"
|
||||||
tokio = { version = "1.47.1", features = ["rt-multi-thread", "tracing"] }
|
tokio = { version = "1.47.1", features = ["rt-multi-thread", "tracing"] }
|
||||||
tracing = "0.1.41"
|
tracing = "0.1.41"
|
||||||
tracing-subscriber = "0.3.19"
|
tracing-subscriber = "0.3.19"
|
||||||
|
|
|
||||||
2
backend/migrations/20250823023643_create_tasks.down.sql
Normal file
2
backend/migrations/20250823023643_create_tasks.down.sql
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
-- Add down migration script here
|
||||||
|
DROP TABLE tasks
|
||||||
10
backend/migrations/20250823023643_create_tasks.up.sql
Normal file
10
backend/migrations/20250823023643_create_tasks.up.sql
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
-- Add up migration script here
|
||||||
|
CREATE TABLE tasks (
|
||||||
|
id UUID PRIMARY KEY NOT NULL,
|
||||||
|
title VARCHAR NOT NULL,
|
||||||
|
description TEXT,
|
||||||
|
status TEXT CHECK(status IN ('todo', 'done', 'backlog')) DEFAULT 'todo',
|
||||||
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
completed_at TIMESTAMP
|
||||||
|
);
|
||||||
13
justfile
13
justfile
|
|
@ -1,6 +1,8 @@
|
||||||
# Temporary until we have a frontend.
|
# Temporary until we have a frontend.
|
||||||
set working-directory := 'backend'
|
set working-directory := 'backend'
|
||||||
|
|
||||||
|
export DATABASE_URL :="sqlite://local.db"
|
||||||
|
|
||||||
dev:
|
dev:
|
||||||
cargo run
|
cargo run
|
||||||
|
|
||||||
|
|
@ -20,3 +22,14 @@ clean:
|
||||||
cargo clean
|
cargo clean
|
||||||
|
|
||||||
|
|
||||||
|
reset-db:
|
||||||
|
sqlx database drop
|
||||||
|
sqlx database create
|
||||||
|
sqlx migrate run
|
||||||
|
|
||||||
|
migrate:
|
||||||
|
sqlx migrate run
|
||||||
|
|
||||||
|
migrate-revert:
|
||||||
|
sqlx migrate revert
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ captains-log/
|
||||||
## Phase 2: Core Database Layer (Days 3-4)
|
## Phase 2: Core Database Layer (Days 3-4)
|
||||||
|
|
||||||
### Task 2.0: Create Initial Database Migration
|
### Task 2.0: Create Initial Database Migration
|
||||||
- [ ] **File**: `backend/migrations/001_create_tasks.sql`
|
- [x] **File**: `backend/migrations/001_create_tasks.sql`
|
||||||
- Create tasks table with all required fields
|
- Create tasks table with all required fields
|
||||||
- Add proper indexes and constraints
|
- Add proper indexes and constraints
|
||||||
- Include created_at, updated_at triggers if needed
|
- Include created_at, updated_at triggers if needed
|
||||||
|
|
@ -77,7 +77,7 @@ captains-log/
|
||||||
- **Expected outcome**: `sqlx migrate run` creates table successfully
|
- **Expected outcome**: `sqlx migrate run` creates table successfully
|
||||||
|
|
||||||
### Task 2.1: Define Task Model
|
### Task 2.1: Define Task Model
|
||||||
- [ ] **File**: `backend/src/database/models.rs`
|
- [x] **File**: `backend/src/database/models.rs`
|
||||||
- Create Task struct with SQLx derives
|
- Create Task struct with SQLx derives
|
||||||
- Add TaskStatus and Priority enums
|
- Add TaskStatus and Priority enums
|
||||||
- Implement proper serialization/deserialization
|
- Implement proper serialization/deserialization
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue