wheels dbmigrate create table
Generate a migration file for creating a new database table.
Synopsis
Alias: wheels db create table
Description
The dbmigrate create table
command generates a migration file that creates a new database table. The generated migration includes the table structure following Wheels conventions.
Parameters
name
string
Yes
-
The name of the table to create
--force
boolean
No
false
Force the creation of the table
--id
boolean
No
true
Auto create ID column as autoincrement ID
primary-key
string
No
"id"
Overrides the default primary key column name
Notes About Column Definition
The generated migration file will contain a basic table structure. You'll need to manually edit the migration file to add columns with their types and options. The migration template includes comments showing how to add columns.
Examples
Create a basic table
Create table without ID column
Create table with custom primary key
Force creation (overwrite existing)
Generated Migration Example
For the command:
Generates a migration file that you can customize:
Use Cases
Standard Entity Table
Create a typical entity table:
Join Table for Many-to-Many
Create a join table without primary key:
Table with Custom Primary Key
Create a table with non-standard primary key:
Best Practices
1. Use Singular Table Names
Wheels conventions expect singular table names:
2. Edit Migration Files
After generating the migration, edit it to add columns:
3. Plan Your Schema
Think through your table structure before creating:
Primary key strategy
Required columns and their types
Foreign key relationships
Indexes needed for performance
Working with the Generated Migration
The command generates a basic migration template. You'll need to edit it to add columns:
Notes
Table names should follow your database naming conventions
The migration automatically handles rollback with dropTable()
Column order in the command is preserved in the migration
Use
wheels dbmigrate up
to run the generated migration
Related Commands
wheels dbmigrate create column
- Add columns to existing tablewheels dbmigrate create blank
- Create custom migrationwheels dbmigrate remove table
- Create table removal migrationwheels dbmigrate up
- Run migrationswheels dbmigrate info
- View migration status
Last updated
Was this helpful?