From: Thierry Parmentelat Date: Tue, 30 Jan 2007 11:27:12 +0000 (+0000) Subject: a micro-framework for handling migrations X-Git-Tag: pycurl-7_13_1~52 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;ds=sidebyside;h=f62304dea30e549193712bb442bf2ebcbb2814bc;p=plcapi.git a micro-framework for handling migrations just create migration scripts named migrations/-up-.sql and myplc will apply them at start time I am unsure whether wildcards are supported in setup.py, checking that.. --- diff --git a/migrations/001-up-subversion.sql b/migrations/001-up-subversion.sql new file mode 100644 index 0000000..3a1903d --- /dev/null +++ b/migrations/001-up-subversion.sql @@ -0,0 +1,4 @@ +-- this is mostly sample code +-- since subversion is also created by the migration code in plc.d/db + +ALTER TABLE plc_db_version ADD subversion integer DEFAULT 0; diff --git a/migrations/README.txt b/migrations/README.txt new file mode 100644 index 0000000..86adddb --- /dev/null +++ b/migrations/README.txt @@ -0,0 +1,3 @@ +Store here migration scripts, named +-up-any-text.sql +with contiguous indices starting with 001 diff --git a/planetlab4.sql b/planetlab4.sql index 2fb0747..c2baf83 100644 --- a/planetlab4.sql +++ b/planetlab4.sql @@ -9,7 +9,7 @@ -- -- Copyright (C) 2006 The Trustees of Princeton University -- --- $Id: planetlab4.sql,v 1.66 2007/01/29 20:13:12 mlhuang Exp $ +-- $Id: planetlab4.sql,v 1.67 2007/01/29 20:48:27 mlhuang Exp $ -- -------------------------------------------------------------------------------- @@ -32,6 +32,7 @@ CREATE AGGREGATE array_accum ( -- Database version CREATE TABLE plc_db_version ( version integer NOT NULL +-- subversion created on demand by plc.d/db ) WITH OIDS; INSERT INTO plc_db_version (version) VALUES (4); diff --git a/setup.py b/setup.py index 60a4ede..bd3f8fb 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: setup.py,v 1.4 2006/10/27 20:08:46 mlhuang Exp $ +# $Id: setup.py,v 1.5 2007/01/09 16:33:16 mlhuang Exp $ # from distutils.core import setup @@ -14,4 +14,5 @@ setup(py_modules = ['ModPython'], packages = ['PLC', 'PLC/Methods', 'PLC/Methods/system'], scripts = ['plcsh', 'Server.py', 'Test.py'], data_files = [('', ['planetlab4.sql']), - ('php', ['php/plc_api.php'])]) + ('php', ['php/plc_api.php']), + ('migrations', ['migrations/*.sql','migrations/README.txt'])])