Migrations
Last updated
Was this helpful?
Last updated
Was this helpful?
Migrations in Novel API are handled by Knex.js
The big difference with Novel is that migrations are auto executed during runtime. This means any changes to the migrations are applied immediately.
During development time, Novel auto-generates Models and the accompanying validation and schema files to be registered within the server as well as made available to you for import.
You can check how models work below
Start by following the tutorial below
Name your table in plural form.
Be careful of your indices and primary keys. Maybe a composite primary key is more useful.
There is no need to add a maximum length to strings.
Make use of .references('table_name.foreign_key')
when defining relationships.
Make use of timestamps for boolean fields.
Make sure you add references to organization ID or account ID where needed.
Avoid using UUID v4s for your Primary Keys. Consider UUID v1/v7, ULID, or normal Big Int.
When prototyping, you may perform trial-and-error on tables and columns.
At 2025.1.0, there is no automatic way to temporarily try your database changes without data loss.
If you need to prototype your database tables temporarily, you will need to:
Delete the migration file row in the _migrations
table in your database
Run knex migrate:rollback
to rollback the change that was made to the database.
Run the migration again with your changes.
2024-12-20 - Initial Documentation