Re: Database migrations

From: Simon Connah <simon(dot)n(dot)connah(at)protonmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: Re: Database migrations
Date: 2021-03-14 09:40:05
Message-ID: iEmEeBaqwt6XevYlGSsaqpYCHDqm6I_dy7udGkeHDvXJ-N13TDsKtI_-2mKFiX-9aMSsbobpbCMt7rJ2x9KjKb2zEZx9Pd8jWwVRUnHiqj8=@protonmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐

On Saturday, March 13th, 2021 at 21:58, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> 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

Hi Tom,

Thank you for the suggestion. I had no idea PostgreSQL had a feature for things like that.

I'll do some reading on the subject but it certainly seems interesting.

Simon.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Simon Connah 2021-03-14 09:47:53 Re: Database migrations
Previous Message Steve Baldwin 2021-03-13 23:19:35 Re: Database migrations