Migration not running!

34 views
Skip to first unread message

armen d

unread,
Nov 25, 2014, 5:55:03 PM11/25/14
to activate-p...@googlegroups.com
Hi, 
The following code isn't creating the version column needed for optimistic offline locking. 
Yet when I look at contents of StorageVersion table, it shows 201404182005 which is timestamp + 400, which would indicate migration ran. Why do you think the column isn't getting created?

Any ideas?
class MultipleVMsMigration extends Migration {
 implicit val dbContext = bDbContext

  def timestamp =  MigrationSettings.Timestamp + 400

  private def createColumnforOptimisticOfflineLocking() {
   table[bEventEntity]
     .addColumn(
       _.column[Long]("version"))


armen d

unread,
Nov 25, 2014, 5:57:38 PM11/25/14
to activate-p...@googlegroups.com
I looked in the code to make sure there isn't another query running at same timestamp. 
I even dropped db schema and ran again, but still don't see version column for each table.

By the way, the function updates several tables at once:

private def createColumnforOptimisticOfflineLocking() {
  table[bEventEntity]
    .addColumn(
      _.column[Long]("version"))
 
  table
[cEventEntity]
    .addColumn(
     _.column[Long]("version"))
 etc
...

Valentin Churavy

unread,
Nov 25, 2014, 6:21:45 PM11/25/14
to activate-p...@googlegroups.com
Did you define a function up that actually runs the migration? See https://github.com/fwbrasil/activate/blob/v1.6/activate-docs/migration.md

Best Valentin

armen d

unread,
Nov 25, 2014, 6:37:28 PM11/25/14
to activate-p...@googlegroups.com
yes here it is:

  override def up {
    customScript {
      createColumnforOptimisticOfflineLocking()
    }
  }

Flavio W. Brasil

unread,
Nov 25, 2014, 6:58:48 PM11/25/14
to armen d, activate-p...@googlegroups.com
Hi Armen,

The problem is probably the “customScript” usage. It should be used only if you are running a custom migration action as a transaction. Try to remove it.

Best,

-- 
Flavio W. Brasil

--
You received this message because you are subscribed to the Google Groups "Activate Persistence Framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persist...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Flavio W. Brasil

unread,
Nov 25, 2014, 6:59:22 PM11/25/14
to armen d, activate-p...@googlegroups.com
There are some usage examples of “customScript” here:


Best,

-- 
Flavio W. Brasil

Message has been deleted

armen d

unread,
Nov 25, 2014, 7:11:46 PM11/25/14
to activate-p...@googlegroups.com, doni...@gmail.com
Hi Flavio,
I removed customScript and it didn't fix it.


class MultipleVMsMigration extends Migration {

 implicit val dbContext = bDbContext

 def timestamp =  MigrationSettings.Timestamp + 150

 override def up {

   table[bEEntity]

     .addColumn(

       _.column[Long]("version"))

   table[bETEntity]

Flavio W. Brasil

unread,
Nov 25, 2014, 7:12:30 PM11/25/14
to armen d, activate-p...@googlegroups.com
Maybe you need to bump the timestamp?

-- 
Flavio W. Brasil

armen d

unread,
Nov 25, 2014, 7:13:15 PM11/25/14
to activate-p...@googlegroups.com, doni...@gmail.com
Do you find it interesting that the StorageVersion contains a timestamp corresponding to the timestamp of this migration?

How can I generally debug this issue, psql via command line and pgadmin GUI doesn't show the version column.

Flavio W. Brasil

unread,
Nov 25, 2014, 7:15:33 PM11/25/14
to armen d, activate-p...@googlegroups.com
If the StorageVersion has a greater timestamp, the migration won’t run. Did you bump the timestamp version after fixing the migration?

-- 
Flavio W. Brasil

armen d

unread,
Nov 30, 2014, 11:40:55 PM11/30/14
to activate-p...@googlegroups.com, doni...@gmail.com
Thanks Flavio.
I bumped the timestamp on the migration and it ran.
To unsubscribe from this group and stop receiving emails from it, send an email to activate-persistence+unsub...@googlegroups.com.

armen d

unread,
Dec 1, 2014, 7:44:48 PM12/1/14
to activate-p...@googlegroups.com, doni...@gmail.com
Hi Flavio,
Can you comment on the following.

1. I noticed that when a migration defined with a certain timestamp 201411261100 ran, it only added 'version' column to some tables, leaving other tables untouched. Have you experienced a partial migration error? I didn't see any errors in logs.

2. Due to problem #1, I needed to re-run migration. What is the best way to re-run a migration? I tried changing the timestamp to a more recent date, but started seeing:

Caused by: net.fwbrasil.activate.storage.relational.JdbcStatementException: Statement exception: ALTER TABLE "xxx" ADD        "version" DECIMAL. Next exception: Some(ERROR: column "version" of relation "xxx" already exists)
        at net.fwbrasil.activate.storage.relational.JdbcRelationalStorage$class.execute(JdbcRelationalStorage.scala:164)

The value in StorageVersion isn't changing either.
Reply all
Reply to author
Forward
0 new messages