a micro-framework for handling migrations
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 30 Jan 2007 11:27:12 +0000 (11:27 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 30 Jan 2007 11:27:12 +0000 (11:27 +0000)
just create migration scripts named
migrations/<nnn>-up-<some-text>.sql and myplc will apply them at start time

I am unsure whether wildcards are supported in setup.py, checking that..

migrations/001-up-subversion.sql [new file with mode: 0644]
migrations/README.txt [new file with mode: 0644]
planetlab4.sql
setup.py

diff --git a/migrations/001-up-subversion.sql b/migrations/001-up-subversion.sql
new file mode 100644 (file)
index 0000000..3a1903d
--- /dev/null
@@ -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 (file)
index 0000000..86adddb
--- /dev/null
@@ -0,0 +1,3 @@
+Store here migration scripts, named
+<nnn>-up-any-text.sql
+with contiguous indices starting with 001
index 2fb0747..c2baf83 100644 (file)
@@ -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);
index 60a4ede..bd3f8fb 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@
 # Mark Huang <mlhuang@cs.princeton.edu>
 # 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'])])