Re: Migrations + Frontbase

From: Jon Nolan (jnola..ebdynamicsinc.com)
Date: Wed Oct 15 2008 - 14:53:48 EDT

  • Next message: Mike Schrag: "Re: Migrations + Frontbase"

    David Holt wrote:
    > Hi Jon,
    >
    > On 15-Oct-08, at 11:18 AM, Jon Nolan wrote:
    >
    >> Good afternoon,
    >>
    >> I'm implementing migrations for the first time. After struggling a
    >> bit with the syntax for the _dbupdater table creation (Frontbase
    >> doesn't like leading underscores without the table name being quoted)
    >> I got things running.
    >
    > You shouldn't need to create this table manually if you're using
    > migrations. If it doesn't exist, it is created automatically. I have not
    > had a problem with the Frontbase plugin.

    Thanks David. I thought so too. The automatic table creation was attempted using:

       CREATE TABLE _dbupdater(lockowner VARCHAR(100), modelname VARCHAR(100) NOT NULL, updatelock INTEGER NOT NULL, version INTEGER NOT NULL);

    This failed and I had to quote table name and run manually to make it work.

       CREATE TABLE "_dbupdater"(lockowner VARCHAR(100), modelname VARCHAR(100) NOT NULL, updatelock INTEGER NOT NULL, version INTEGER NOT NULL);

    >> At least I was able to run my initial migration test:
    >>
    >> public class TestMigration0 extends Migration {
    >>
    >> ..verride
    >> public void downgrade(EOEditingContext ec,
    >> ERXMigrationDatabase database) throws Throwable {
    >> ...
    >> }
    >>
    >> ..verride
    >> public void upgrade(EOEditingContext ec, ERXMigrationDatabase
    >> database) throws Throwable {
    >> ERXMigrationTable table =
    >> database.newTableNamed("NEW_TABLE");
    >> table.newIntegerColumn("NEW_TABLE_ID", false);
    >> table.newStringColumn("NEW_TABLE_STRING_1", 100, true);
    >> table.newStringColumn("NEW_TABLE_STRING_2", 100, true);
    >> table.newStringColumn("NEW_TABLE_STRING_3", 100, true);
    >> table.create();
    >> table.setPrimaryKey("NEW_TABLE_ID");
    >>
    >> }
    >>
    >> }
    >>
    >> So far so good. I then tried to implement a second migration class:
    >>
    >> public class TestMigration1 extends Migration {
    >>
    >> ..verride
    >> public void downgrade(EOEditingContext ec,
    >> ERXMigrationDatabase database) throws Throwable {
    >> ...
    >> }
    >>
    >> ..verride
    >> public void upgrade(EOEditingContext ec, ERXMigrationDatabase
    >> database) throws Throwable {
    >> ERXMigrationTable table =
    >> database.existingTableNamed("NEW_TABLE");
    >> table.newStringColumn("NEW_TABLE_STRING_4", 100, true);
    >> }
    >>
    >> }
    >>
    >
    > Your code looks right to me. Could "table" be a reserved word? Try
    > "testTable" or something?

    It's compiling fine. But I tried testTable anyway and still the same problem. I also changed the table name to "ABC123" and the column/index names in the same fashion. Same syntax; same error.

    >> This results in a failure due to invalid SQL. The alter statement
    >> looks something like this:
    >>
    >> alter table NEW_TABLE null NEW_TABLE_STRING_4 VARCHAR(100)
    >
    > not sure where this "null" is coming from. See above....
    >
    >>
    >> That's obviously not going to work. Would any of you have any idea
    >> where I went wrong?
    >>
    >> Thanks,
    >> Jon
    >>
    >> OSX 10.5.5
    >> Eclipse 3.3.2
    >> WOLips 3.3.5503
    >> WO 5.4.3
    >> Wonder 10/12/08
    >> Frontbase 4.2.7



    This archive was generated by hypermail 2.0.0 : Wed Oct 15 2008 - 14:54:30 EDT