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 1lLCNi-0000Ep-La for pgsql-novice@arkaria.postgresql.org; Sat, 13 Mar 2021 22:05:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lLCNh-0003ip-Bb for pgsql-novice@arkaria.postgresql.org; Sat, 13 Mar 2021 22:05:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLCNf-0003dU-Oy for pgsql-novice@lists.postgresql.org; Sat, 13 Mar 2021 22:05:09 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lLCNa-0001p7-NX for pgsql-novice@lists.postgresql.org; Sat, 13 Mar 2021 22:05:07 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id D6D635C0091; Sat, 13 Mar 2021 17:04:59 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Sat, 13 Mar 2021 17:04:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aroman.sh; h= content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; s=fm2; bh=B Sm01nrPh0dsgAYpv8zRLDZSrjpk6wX/3MniGqDebZI=; b=UBfvOMl3a59ebFTJH NsGo92znDVeWndVQO6ob/alDHTB6WRuRNc3d8RAi1EEDrVld/UhKfBevqIX9L35R kvx3dYLIcbTxTW3fAay9dUXfw8Ibn6495mwNhC44jSpnltt1gK7D0/P6Aviv22lh k0Ca7aMGKR+j10/wE/bX26j9xSBW3WViIw6zP7yi/XcLV96gq3ukRHKMYLJbbFm0 YnS3VDe7LMsH4lWsAYQaTUuQBd8l5hcP+D40RSJU6X/272jG4XD/p29dwx1i3JUq shpRsBPYgiRq4UnB8xukbyXhCdwBoNF4M7UkXc8Q9hAR73nAHfTXUWsOFMPlcOIF fyeVQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=BSm01nrPh0dsgAYpv8zRLDZSrjpk6wX/3MniGqDeb ZI=; b=U2MlYQrs34N43WLbbZ0lH8eCuek+JckMF/ujiSEGw/NprR6Wf0Z/mHsZh l5x6nU3rGvTb8gLqKXxEdBjgjE5GeOYEpB+o+kNypOCNhY+pUEpJeztQ01c5/Pls YOLPto2NExn1X215n2rMt9GDxlIVrtnNObhYYs3Dk5sqS6Fje+LD7WRZY9zyK+mZ hXcVnYdnGyAo5+sU0P+u/kSH9n5X5A408wbVvcKKUsFR+qyvOmkAewu7XIPL8lbJ /sHf30woTIXREMtWgDOqRWOWu/njDt31zVMAoEnu9TxG/xA2qZUUja58hsGjNYIk vS9DOn8ZdFUQzKT/PaQM0qadI3kkQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledruddvgedgudehgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpegtggfuhfgjfffgkfhfvffosehtqhhmtdhhtdejnecuhfhrohhmpeetlhgv jhgrnhgurhhopgftohhmjohnuceorghlvghjrghnughrohesrghrohhmrghnrdhshheqne cuggftrfgrthhtvghrnhepgffhudevuedtiedvgfdvffethedugfeuveeufeetteevfeeh uddvgfekfeelleeknecuffhomhgrihhnpehknhgvgihjshdrohhrghenucfkphepudeltd drgeefrddvvdekrddugeehnecuufhprghmkfhppfgvthifohhrkhepudeltddrgeefrddv vdekrddugeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprghlvghjrghnughrohesrghrohhmrghnrdhshh X-ME-Proxy: Received: from [192.168.1.53] (unknown [190.43.228.145]) by mail.messagingengine.com (Postfix) with ESMTPA id 5D12D240057; Sat, 13 Mar 2021 17:04:57 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: Database migrations From: =?utf-8?Q?Alejandro_Rom=C3=A1n?= In-Reply-To: Date: Sat, 13 Mar 2021 17:04:55 -0500 Cc: "pgsql-novice@lists.postgresql.org" Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Simon Connah X-Mailer: Apple Mail (2.3654.60.0.2.21) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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(=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 stores 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