From a4fff6494f3a488678eadeb28044c9f8c97e10be Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 20 Feb 2006 22:41:59 +0000 Subject: [PATCH] Define the schema in code, fixed up some bugs. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3871 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- build.xml | 1 - .../admin/server/DatabaseConfigRegistry.java | 2 +- .../server/persist/ConfigRepository.java | 13 ++++++---- src/sql/admin/config.sql | 25 ------------------- 4 files changed, 9 insertions(+), 32 deletions(-) delete mode 100644 src/sql/admin/config.sql diff --git a/build.xml b/build.xml index 5e18e1338..149252d03 100644 --- a/build.xml +++ b/build.xml @@ -205,7 +205,6 @@ - diff --git a/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java b/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java index 3eb04345c..34631744a 100644 --- a/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java +++ b/src/java/com/threerings/admin/server/DatabaseConfigRegistry.java @@ -56,7 +56,7 @@ public class DatabaseConfigRegistry extends ConfigRegistry // documentation inherited protected ObjectRecord createObjectRecord (String path, DObject object) { - return null; + return new DatabaseObjectRecord(path, object); } protected class DatabaseObjectRecord extends ObjectRecord diff --git a/src/java/com/threerings/admin/server/persist/ConfigRepository.java b/src/java/com/threerings/admin/server/persist/ConfigRepository.java index 4a6064d67..f2e6289e1 100644 --- a/src/java/com/threerings/admin/server/persist/ConfigRepository.java +++ b/src/java/com/threerings/admin/server/persist/ConfigRepository.java @@ -90,17 +90,20 @@ public class ConfigRepository extends JORARepository protected void migrateSchema (Connection conn, DatabaseLiaison liaison) throws SQLException, PersistenceException { - if (!JDBCUtil.tableExists(conn, "CONFIG")) { - Log.info("Creating admin.config schema..."); - JDBCUtil.loadSchema(conn, "admin/config.sql"); - } + JDBCUtil.createTableIfMissing(conn, "CONFIG", new String[] { + "OBJECT VARCHAR(255) NOT NULL", + "FIELD VARCHAR(255) NOT NULL", + "VALUE TEXT NOT NULL", + "PRIMARY KEY (OBJECT, FIELD)", + }); } // documentation inherited protected void createTables (Session session) { _ctable = new Table( - ConfigDatum.class.getName(), "CONFIG", session, "OBJECT", true); + ConfigDatum.class.getName(), "CONFIG", session, + new String[] { "OBJECT", "FIELD" }, true); } protected Table _ctable; diff --git a/src/sql/admin/config.sql b/src/sql/admin/config.sql deleted file mode 100644 index 4334dbb6b..000000000 --- a/src/sql/admin/config.sql +++ /dev/null @@ -1,25 +0,0 @@ -/** - * $Id$ - * - * Schema for the Admin services configuration table. - */ - -drop table if exists CONFIG; - -/** - * Contains all registered configuration data. - */ -CREATE TABLE CONFIG -( - /** The configuration object with which this datum is associated. */ - OBJECT VARCHAR(255) NOT NULL, - - /** The configuration object field name. */ - FIELD VARCHAR(255) NOT NULL, - - /** The value of the object field. */ - VALUE TEXT NOT NULL, - - /** Defines our table keys. */ - PRIMARY KEY (OBJECT, FIELD) -);