akron db init

Initialize a new Akron project with schema configuration and migration setup.

NEW COMMAND

akron db init

Initialize a new Akron project with schema configuration file and migration directory structure.

Syntax

1akron db init [OPTIONS]

Options

OptionDescriptionDefault
--providerDatabase provider (sqlite, mysql, postgresql, mongodb)sqlite
--urlCustom database connection URLProvider default
--forceOverwrite existing akron.json filefalse

Examples

Basic SQLite Project

Initialize a new project with SQLite database (default):

1akron db init
Expected Output
āœ… Initialized Akron project
   Provider: sqlite
   Database: sqlite:///app.db
   Schema file: akron.json

šŸ“ Next steps:
   1. Edit akron.json to define your schema
   2. Run 'akron db makemigrations' to generate migrations
   3. Run 'akron db migrate' to apply migrations

PostgreSQL Project

Initialize with PostgreSQL and custom connection URL:

1akron db init --provider postgresql --url "postgres://user:password@localhost:5432/myapp"
Expected Output
āœ… Initialized Akron project
   Provider: postgresql
   Database: postgres://user:password@localhost:5432/myapp
   Schema file: akron.json

šŸ“ Next steps:
   1. Edit akron.json to define your schema
   2. Run 'akron db makemigrations' to generate migrations
   3. Run 'akron db migrate' to apply migrations

Force Overwrite

Overwrite existing configuration:

1akron db init --provider mysql --force
Expected Output
āœ… Initialized Akron project
   Provider: mysql
   Database: mysql://user:password@localhost:3306/database
   Schema file: akron.json

šŸ“ Next steps:
   1. Edit akron.json to define your schema
   2. Run 'akron db makemigrations' to generate migrations
   3. Run 'akron db migrate' to apply migrations

Generated Files

akron.json

The main schema configuration file:

1{
2 "database": {
3 "provider": "sqlite",
4 "url": "sqlite:///app.db"
5 },
6 "tables": {
7 "User": {
8 "columns": {
9 "id": {
10 "type": "int",
11 "primaryKey": true,
12 "autoIncrement": true
13 },
14 "email": {
15 "type": "string",
16 "unique": true,
17 "nullable": false
18 },
19 "name": {
20 "type": "string",
21 "nullable": true
22 },
23 "createdAt": {
24 "type": "datetime",
25 "default": "now"
26 }
27 }
28 }
29 }
30}

.akron/ Directory

Migration tracking directory structure:

1.akron/
2ā”œā”€ā”€ schema_snapshots.json # Schema change tracking
3└── (migration files) # Generated migration files

Default Database URLs

ProviderDefault URLNotes
sqlitesqlite:///app.dbCreates local file database
mysqlmysql://user:password@localhost:3306/databaseUpdate credentials before use
postgresqlpostgres://user:password@localhost:5432/databaseUpdate credentials before use
mongodbmongodb://localhost:27017/databaseDefault local MongoDB

Next Steps

After initialization:

  1. Edit akron.json to define your database schema
  2. Run akron db makemigrations to generate initial migrations
  3. Run akron db migrate to create your database tables
  4. Start building your application with Akron ORM