Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLNM1-0001mz-JF for pgsql-novice@arkaria.postgresql.org; Sun, 14 Mar 2021 09:48:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLNM0-0005RT-A2 for pgsql-novice@arkaria.postgresql.org; Sun, 14 Mar 2021 09:48:08 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLNM0-0005RL-3R for pgsql-novice@lists.postgresql.org; Sun, 14 Mar 2021 09:48:08 +0000 Received: from mail-40134.protonmail.ch ([185.70.40.134]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLNLw-0003Mx-No for pgsql-novice@lists.postgresql.org; Sun, 14 Mar 2021 09:48:07 +0000 Date: Sun, 14 Mar 2021 09:47:53 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1615715281; bh=cQp6saHqJsMTdEfKjJD9Rr/dTd4hV/5lM8e3CMhiHSY=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=UaA+6uyTthQc3Hh5b4dR0eX8bddSCBOGCfiuUaCvmvIZq2X27uDJ0hI4R2Dwu4LNo BCt6HHpkgbDiuZ+Pg10preCUlvpRdnnSto830f/orr1uNpNdokKxvSQ8WMcz6IQdwS VtUpQlJ8Pn0HC/7kYcwj1lR2FswRYiZ2VOvaAtqo= To: =?utf-8?Q?Alejandro_Rom=C3=A1n?= From: Simon Connah Cc: "pgsql-novice@lists.postgresql.org" Reply-To: Simon Connah Subject: Re: Database migrations Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=10.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM shortcircuit=no autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on mailout.protonmail.ch List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 Original Me= ssage =E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90=E2=80=90 On Saturday, March 13th, 2021 at 22:04, Alejandro Rom=C3=A1n wrote: > Hello, > > > I was thinking about just having a bunch of SQL files with a version nu= mber and date and applying them to the database from oldest to newest (with= a table storing information for files that have already been processed). D= oes this sound like a reasonable solution? > > It does. Actually, there is a known JS library that does exactly that: Kn= ex.js (1). It allows you to define your SQL in plain JS (e.g. `knex.schema.= createTable(=E2=80=98users=E2=80=99, =E2=80=A6)`). It will then keep track = of which migrations (JS files) have been ran and which need to be run. It s= tores this metadata in a table called =E2=80=9Cmigrations=E2=80=9D (you can= configure the exact name). > > (1) http://knexjs.org/#Migrations > > Best wishes, > > Alejandro Hi Alejandro, Thank you for the information. I'll read through the documentation for that= as well. Having everything in JavaScript would be quite helpful in the lon= g run I think but I do like the idea of extensions as well. I'll do some te= sting and see which option works out best. Simon.