Parham Doustdar
Parham Doustdar

Reputation: 2039

YII Migration History Not Being Saved Into Database

I'm using YII 1.1.12. When I do:

yiic migrate

inside the protected folder of my application, I get told that there is a new migration to be applied. I answer "Yes" so that the migration would be applied. After a while, I get:

*** applied m121220_121256_initialize_database (time: 6.060s)
Migrated up successfully.

All is fine up to this point. Then when I type 'yiic migrate', instead of being told that there is no new migration, I get told that:

Yii Migration Tool v1.0 (based on Yii v1.1.12)

Total 1 new migration to be applied:
    m121220_121256_initialize_database

Apply the above migration? (yes|no) [no]:

WhenI check the tbl_migration table, the only thing in there is the base migration. There's nothing aboutinitialize_database.

Any ideas?

Upvotes: 1

Views: 629

Answers (2)

Parham Doustdar
Parham Doustdar

Reputation: 2039

I realised the problem was that the sql commands I was running straight from PHPMyAdmin contained a transaction. When I removed the lines about transactions, the database row in the yii_migration table was inserted successfully. I'm not sure why this should be, but there it is.

Upvotes: 0

Paystey
Paystey

Reputation: 3242

Does your migration create the database? If so it might be throwing Yii off, and it's creating the migration structure at the start and then can't insert into, I'm not sure what the behaviour would be.

If m121220_121256_initialize_database is doing any kind of destructive work then it's probably a good idea to use yiic migrate mark 121220_121256 to manually set the database to this migration after you've ran it.

That way you can do further tests to see whether it's a migration bug or something destructive in the migration like dropping/creating a database.

Upvotes: 1

Related Questions