Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
user:kluong:improvement_-_use_a_database_migration_tool [2022/02/17 01:23] kluong |
user:kluong:improvement_-_use_a_database_migration_tool [2022/02/17 01:26] (current) kluong |
||
---|---|---|---|
Line 11: | Line 11: | ||
Manually executing commands works, although it can be a little more slow and error prone. Database migrations are a technique of codifying those changes in software, and executing those changes in an automated fashion. This technique is popular enough that many popular web frameworks such as Ruby on Rails or Django have built-in support for migrations. | Manually executing commands works, although it can be a little more slow and error prone. Database migrations are a technique of codifying those changes in software, and executing those changes in an automated fashion. This technique is popular enough that many popular web frameworks such as Ruby on Rails or Django have built-in support for migrations. | ||
+ | |||
+ | ===== Migrations ===== | ||
Let me explain a little with an example. Consider we want to create a pretty simple table in postgres (or some other database like sqlite3: | Let me explain a little with an example. Consider we want to create a pretty simple table in postgres (or some other database like sqlite3: | ||
Line 89: | Line 91: | ||
</code> | </code> | ||
+ | Running migrate.py executes both steps automatically, and also creates some extra tables to keep track of the state of the migrations, letting us not have to worry about the current schema. | ||
+ | ===== Concluding ===== | ||
- | + | Adding tables and modifications would be much easier to audit / run in production if we had a tool like this. Migrations could run at the beginning of a the startup sequence for the gateway for example and since the changes are checked into version control they can be audited and approved with the normal workflow. | |
- | It could be useful to use a database migration tool for the gateway like https://flywaydb.org/. Adding tables would be much easier to audit / run in production if we had a tool like this. Migrations could run before the application starts up for example and since they're checked into version control they can be audited and approved with the normal workflow. | + | |