From: | Alejandro Román <alejandro(at)aroman(dot)sh> |
---|---|
To: | Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com> |
Cc: | "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Database migrations |
Date: | 2021-03-13 22:04:55 |
Message-ID: | D7AAB6AC-FCCB-4C50-84F6-3E98FF29D35D@aroman.sh |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hello,
> I was thinking about just having a bunch of SQL files with a version number and date and applying them to the database from oldest to newest (with a table storing information for files that have already been processed). Does this sound like a reasonable solution?
It does. Actually, there is a known JS library that does exactly that: Knex.js (1). It allows you to define your SQL in plain JS (e.g. `knex.schema.createTable(‘users’, …)`). It will then keep track of which migrations (JS files) have been ran and which need to be run. It stores this metadata in a table called “migrations” (you can configure the exact name).
(1) http://knexjs.org/#Migrations
Best wishes,
Alejandro
From | Date | Subject | |
---|---|---|---|
Next Message | Steve Baldwin | 2021-03-13 23:19:35 | Re: Database migrations |
Previous Message | Tom Lane | 2021-03-13 21:58:35 | Re: Database migrations |