A modern framework for building full-stack applications with TypeScript.
- Type-safe database operations with SQLite
- Multi-schema support with separate database files
- Automatic migration generation similar to Drizzle CLI
- Interactive schema management with destructive operation prompts
- Modern CLI with comprehensive commands
# Start development server
ob dev
# Build for production
ob build
# Apply migrations
ob migrate
# Apply migrations for specific schema
ob migrate --schema myapp
# Check migration status
ob migrate status
# Check migration status for specific apps
ob migrate status --apps myapp,otherapp
# Push schema changes (interactive)
ob push
# Push schema changes for specific apps
ob push --apps myapp,otherapp
# Force push (no prompts)
ob push --apps myapp --force
# Generate migration by comparing databases
ob generate myapp
# Generate blank migration file
ob generate myapp --blank
# Type check
ob typecheck
# Generate types
ob typegen
Oxbase provides a comprehensive migration system similar to Drizzle CLI with built-in migration tracking:
The system automatically tracks applied migrations using a __oxbase_migrations
table in each database schema:
- Prevents duplicate migrations: Only applies migrations that haven't been applied yet
- Migration status: Check which migrations are pending or already applied
- Checksum verification: Detects if migration files have been modified
- Timestamp tracking: Records when each migration was applied
The generate
command creates SQL migration files by comparing the current database state with the desired schema:
# Generate migration for an app
ob generate myapp
This will:
- Create temporary databases (
temp_migrate
andtemp_push
) - Apply existing migrations to
temp_migrate
(current state) - Apply schema push to
temp_push
(desired state) - Compare the two databases and generate SQL migration files
- Handle destructive operations with interactive prompts
- Create migration files in
./apps/myapp/migrations/
- Clean up temporary databases
project/
├── migrations/
│ ├── main/
│ │ ├── 20241201T120000_main_migration.sql
│ │ └── 20241201T130000_main_update.sql
│ └── myapp/
│ ├── 20241201T140000_myapp_migration.sql
│ └── 20241201T150000_myapp_update.sql
└── apps/
└── myapp/
└── migrations/
├── 001_legacy_migration.sql
└── 002_legacy_update.sql
- ✅
CREATE TABLE
- ✅
DROP TABLE
- ✅
ALTER TABLE ADD COLUMN
- ✅
ALTER TABLE DROP COLUMN
- ✅
ALTER TABLE RENAME COLUMN
⚠️ ALTER TABLE ALTER COLUMN
(requires table recreation in SQLite)
Each schema gets its own database file with migration tracking:
.oxbase_data/database/
├── main/
│ └── main.db (includes __oxbase_migrations table)
├── myapp/
│ └── myapp.db (includes __oxbase_migrations table)
└── otherapp/
└── otherapp.db (includes __oxbase_migrations table)
project/
├── apps/
│ ├── myapp/
│ │ ├── myapp.app.ts
│ │ ├── entities/
│ │ │ └── user.entity.ts
│ │ └── migrations/
│ │ └── 001_initial.sql
│ └── otherapp/
│ └── otherapp.app.ts
├── migrations/
│ ├── main/
│ └── myapp/
├── oxbase.config.ts
└── package.json
Create oxbase.config.ts
in your project root:
import { defineConfig } from 'oxbase';
export default defineConfig({
// Your configuration here
});
- Install Oxbase:
npm install oxbase
- Create your first app:
mkdir -p apps/myapp
- Create an app configuration:
// apps/myapp/myapp.app.ts
export default {
name: 'myapp',
// Your app configuration
};
- Generate and apply migrations:
# Generate migration by comparing current state with desired schema
ob generate myapp
# Apply the generated migration
ob migrate
# Or apply migrations for specific schema
ob migrate --schema myapp
-
Define your entities in
apps/myapp/entities/
-
Generate migration to see what changes are needed:
ob generate myapp
-
Review the generated SQL in
apps/myapp/migrations/
-
Apply the migration:
ob migrate
-
Push schema changes (if needed):
ob push --apps myapp
MIT