• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Migrations and new not null columns with default values
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Migrations and new not null columns with default values


  • Subject: Migrations and new not null columns with default values
  • From: Farrukh Ijaz <email@hidden>
  • Date: Thu, 16 Sep 2010 10:07:12 +0300

Hi,

Using Migrations I faced an issue. There is a table "TEST_TABLE" with existing data. I added a "Not Null" column "TEST_COLUMN" with default value "0". When I started migration, it failed to execute with following message:

Caused by: org.postgresql.util.PSQLException: ERROR: column "is_dynamic_integer" contains null values

The migration code is below which failed:

ERXMigrationTable testTable = database.existingTableNamed("TEST_TABLE");
testTable.newIntegerColumn("TEST_COLUMN", false, 0);

Here is the modified version that works:

ERXMigrationTable testTable = database.existingTableNamed("TEST_TABLE");
testTable.newIntegerColumn("TEST_COLUMN", true);
ERXJDBCUtilities.executeUpdateScript(database.adaptorChannel(), "UPDATE TEST_TABLE SET TEST_COLUMN = 0");
ERXMigrationColumn testColumn = testTable.existingColumnNamed("TEST_COLUMN");
testColumn.setAllowsNull(false);
testColumn.setDefaultValue(0);

Is this something I should always do for any additional Not Null column?

Thanks,

Farrukh
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Migrations and new not null columns with default values
      • From: Farrukh Ijaz <email@hidden>
  • Prev by Date: Re: Webobjects-dev Digest, Vol 7, Issue 570
  • Next by Date: Re: Migrations and new not null columns with default values
  • Previous by thread: Re: Webobjects-dev Digest, Vol 7, Issue 570
  • Next by thread: Re: Migrations and new not null columns with default values
  • Index(es):
    • Date
    • Thread