From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
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 21:58:35 |
Message-ID: | 2731142.1615672715@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com> writes:
> I'm sorry if this is a rather stupid question but I'm fairly new to databases and was wondering if anyone could offer some advice?
> I have an app I am developing using Node.js and PostgreSQL 13.2. I have the basic tables I want to start with but I know that as development progresses change is going to be required. Since this is an open-source project people are going to want to upgrade from one version to the next and that might require changes to the database structure. What is the best way to handle this?
> 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?
> If not could someone point me in the right direction, please?
If I understand your requirements properly, this is already largely
implemented in PG's "extension" infrastructure. The system can keep
track of which version of an extension is installed, and apply the
correct delta script on request for an upgrade (or downgrade).
See here:
https://www.postgresql.org/docs/current/extend-extensions.html
The documentation mostly talks about extensions that have some
underlying C code (in a .so library file). But it's perfectly possible
to have an extension that consists only of SQL definitions.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Alejandro Román | 2021-03-13 22:04:55 | Re: Database migrations |
Previous Message | Simon Connah | 2021-03-13 21:40:27 | Database migrations |