Learn how to add Thin Backend to your react application
Migrations play an important role in the development of an Thin Backend based application.
Whenever you add or change a table in the Schema Designer, the changes will only be applied to the in-memory schema. The actual postgres database will never by touched by the schema designer directly.
You can think of this like in a git workflow: In git changes are only applied to the repository history when you do a git commit. In Thin Backend this 'git commit' is running a database migration.
In Thin Backend a database migration is a list of SQL statements that will be run inside the postgres database when the migration is run.
Open the Schema Designer. When a migration is required, Thin Backend shows this warning:
Click the Migrate DB button on the warning message. This will create a new migration.
Unmigrated Changes message is not shown: Click the
Migrations tab at the top, then click on
+ Add Migration.
Next you will see an prefilled list of SQL statements that should be executed to bring your Schema in Sync with your actual database:
Run Migration. This will run the
CREATE TABLE tasks (..) statement.
You can toggle the
Create only switch to avoid running the migration just now. If enabled, the migration will be created and will be visible on the migrations overview. That way you can run it at a later point in time. This can be useful when dealing with large tables, where you might want to run the migration on the weekend, so users don't have a interuption of your app.
Migrations are always run inside a transaction, so an error in the migration will not cause an incosistent state.
If you need any help or input, feel free to ask in the Thin Community Forum.