Skip to content

Initialize database schema (Pure JSON, no migrations) - #141

Merged
malibio merged 2 commits into
mainfrom
feature/issue-102-initialize-db-schema
Oct 3, 2025
Merged

malibio merged 2 commits into
mainfrom
feature/issue-102-initialize-db-schema

Conversation

@malibio

@malibio malibio commented Oct 3, 2025

Copy link
Copy Markdown
Collaborator

Closes #102

## Changes

### IndexManager Module
- Created `IndexManager` struct for dynamic JSON path index creation
- Supports query-driven index optimization
- Safe CREATE INDEX operations (no ALTER TABLE risk)
- Methods: create_json_path_index, index_exists, list_indexes
- Comprehensive test coverage

### Core Schema Seeding
- Added `seed_core_schemas()` method to DatabaseService
- Seeded 5 core schemas as nodes:
  - task: status, assignee, due_date, description fields
  - person: name, email fields
  - date: date field
  - project: name, status fields
  - text: minimal schema (content only)
- Uses INSERT OR IGNORE for idempotent initialization
- Schema-as-Node pattern with properties JSON

### Testing
- Added tests for schema seeding verification
- Verified schema properties structure
- Confirmed idempotent initialization
- All tests passing, cargo check and clippy clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio
malibio force-pushed the feature/issue-102-initialize-db-schema branch from 0df7463 to 2e06f0c Compare October 3, 2025 18:52
## Critical Security Fix
- **SQL Injection Prevention**: Added input validation to IndexManager methods
- validate_identifier() helper prevents malicious inputs
- Comprehensive security tests cover all injection vectors
- Fixed error semantics (LibsqlError instead of initialization_failed)

## Improvements
- **Type-Safe Schemas**: Use json! macro for compile-time validation
- **Performance Indexes**: Added before_sibling_id and created_at indexes
- **Better Test Coverage**: Validate ALL schema fields, not just first

## Changes Summary

### IndexManager Security (packages/core/src/db/index_manager.rs)
- Added validate_identifier() for SQL injection prevention
- Updated create_json_path_index() with validation
- Updated index_exists() with validation
- Updated list_indexes() with validation
- Fixed connection error mapping (LibsqlError)
- Added 3 security test suites (56 total assertions)

### Schema Improvements (packages/core/src/db/database.rs)
- Refactored seed_core_schemas() to use json! macro
- Added before_sibling_id index for sibling ordering
- Added created_at index for temporal queries
- Improved test_schema_properties_structure() to validate all fields

## Test Results
- All 66 tests passing ✅
- cargo check clean ✅
- cargo clippy clean ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio
malibio merged commit 79a5017 into main Oct 3, 2025
@malibio
malibio deleted the feature/issue-102-initialize-db-schema branch October 3, 2025 20:49
malibio added a commit that referenced this pull request Feb 4, 2026
* Initialize database schema with Pure JSON architecture (addresses #102)

## Changes

### IndexManager Module
- Created `IndexManager` struct for dynamic JSON path index creation
- Supports query-driven index optimization
- Safe CREATE INDEX operations (no ALTER TABLE risk)
- Methods: create_json_path_index, index_exists, list_indexes
- Comprehensive test coverage

### Core Schema Seeding
- Added `seed_core_schemas()` method to DatabaseService
- Seeded 5 core schemas as nodes:
  - task: status, assignee, due_date, description fields
  - person: name, email fields
  - date: date field
  - project: name, status fields
  - text: minimal schema (content only)
- Uses INSERT OR IGNORE for idempotent initialization
- Schema-as-Node pattern with properties JSON

### Testing
- Added tests for schema seeding verification
- Verified schema properties structure
- Confirmed idempotent initialization
- All tests passing, cargo check and clippy clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address code review feedback: security fixes and improvements

## Critical Security Fix
- **SQL Injection Prevention**: Added input validation to IndexManager methods
- validate_identifier() helper prevents malicious inputs
- Comprehensive security tests cover all injection vectors
- Fixed error semantics (LibsqlError instead of initialization_failed)

## Improvements
- **Type-Safe Schemas**: Use json! macro for compile-time validation
- **Performance Indexes**: Added before_sibling_id and created_at indexes
- **Better Test Coverage**: Validate ALL schema fields, not just first

## Changes Summary

### IndexManager Security (packages/core/src/db/index_manager.rs)
- Added validate_identifier() for SQL injection prevention
- Updated create_json_path_index() with validation
- Updated index_exists() with validation
- Updated list_indexes() with validation
- Fixed connection error mapping (LibsqlError)
- Added 3 security test suites (56 total assertions)

### Schema Improvements (packages/core/src/db/database.rs)
- Refactored seed_core_schemas() to use json! macro
- Added before_sibling_id index for sibling ordering
- Added created_at index for temporal queries
- Improved test_schema_properties_structure() to validate all fields

## Test Results
- All 66 tests passing ✅
- cargo check clean ✅
- cargo clippy clean ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Feb 5, 2026
* Initialize database schema with Pure JSON architecture (addresses #102)

## Changes

### IndexManager Module
- Created `IndexManager` struct for dynamic JSON path index creation
- Supports query-driven index optimization
- Safe CREATE INDEX operations (no ALTER TABLE risk)
- Methods: create_json_path_index, index_exists, list_indexes
- Comprehensive test coverage

### Core Schema Seeding
- Added `seed_core_schemas()` method to DatabaseService
- Seeded 5 core schemas as nodes:
  - task: status, assignee, due_date, description fields
  - person: name, email fields
  - date: date field
  - project: name, status fields
  - text: minimal schema (content only)
- Uses INSERT OR IGNORE for idempotent initialization
- Schema-as-Node pattern with properties JSON

### Testing
- Added tests for schema seeding verification
- Verified schema properties structure
- Confirmed idempotent initialization
- All tests passing, cargo check and clippy clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address code review feedback: security fixes and improvements

## Critical Security Fix
- **SQL Injection Prevention**: Added input validation to IndexManager methods
- validate_identifier() helper prevents malicious inputs
- Comprehensive security tests cover all injection vectors
- Fixed error semantics (LibsqlError instead of initialization_failed)

## Improvements
- **Type-Safe Schemas**: Use json! macro for compile-time validation
- **Performance Indexes**: Added before_sibling_id and created_at indexes
- **Better Test Coverage**: Validate ALL schema fields, not just first

## Changes Summary

### IndexManager Security (packages/core/src/db/index_manager.rs)
- Added validate_identifier() for SQL injection prevention
- Updated create_json_path_index() with validation
- Updated index_exists() with validation
- Updated list_indexes() with validation
- Fixed connection error mapping (LibsqlError)
- Added 3 security test suites (56 total assertions)

### Schema Improvements (packages/core/src/db/database.rs)
- Refactored seed_core_schemas() to use json! macro
- Added before_sibling_id index for sibling ordering
- Added created_at index for temporal queries
- Improved test_schema_properties_structure() to validate all fields

## Test Results
- All 66 tests passing ✅
- cargo check clean ✅
- cargo clippy clean ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Feb 26, 2026
* Initialize database schema with Pure JSON architecture (addresses #102)

## Changes

### IndexManager Module
- Created `IndexManager` struct for dynamic JSON path index creation
- Supports query-driven index optimization
- Safe CREATE INDEX operations (no ALTER TABLE risk)
- Methods: create_json_path_index, index_exists, list_indexes
- Comprehensive test coverage

### Core Schema Seeding
- Added `seed_core_schemas()` method to DatabaseService
- Seeded 5 core schemas as nodes:
  - task: status, assignee, due_date, description fields
  - person: name, email fields
  - date: date field
  - project: name, status fields
  - text: minimal schema (content only)
- Uses INSERT OR IGNORE for idempotent initialization
- Schema-as-Node pattern with properties JSON

### Testing
- Added tests for schema seeding verification
- Verified schema properties structure
- Confirmed idempotent initialization
- All tests passing, cargo check and clippy clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address code review feedback: security fixes and improvements

## Critical Security Fix
- **SQL Injection Prevention**: Added input validation to IndexManager methods
- validate_identifier() helper prevents malicious inputs
- Comprehensive security tests cover all injection vectors
- Fixed error semantics (LibsqlError instead of initialization_failed)

## Improvements
- **Type-Safe Schemas**: Use json! macro for compile-time validation
- **Performance Indexes**: Added before_sibling_id and created_at indexes
- **Better Test Coverage**: Validate ALL schema fields, not just first

## Changes Summary

### IndexManager Security (packages/core/src/db/index_manager.rs)
- Added validate_identifier() for SQL injection prevention
- Updated create_json_path_index() with validation
- Updated index_exists() with validation
- Updated list_indexes() with validation
- Fixed connection error mapping (LibsqlError)
- Added 3 security test suites (56 total assertions)

### Schema Improvements (packages/core/src/db/database.rs)
- Refactored seed_core_schemas() to use json! macro
- Added before_sibling_id index for sibling ordering
- Added created_at index for temporal queries
- Improved test_schema_properties_structure() to validate all fields

## Test Results
- All 66 tests passing ✅
- cargo check clean ✅
- cargo clippy clean ✅

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Initialize database schema (Pure JSON, no migrations)

1 participant