migrate

Migrations

flock of migrating canada geese birds flying at sunset

Yes, migration! I would like some too! Who doesn’t love to travel?

PK Shiu has an amazing explanation of how South’s migration works here.

looking at my wagweb migrations, I realise:

from django.db import models
class Migration(SchemaMigration):
def forwards(self, orm):
 # Adding model 'BlogPage'
 db.create_table(u'wagweb_blogpage', (
 (u'page_ptr', self.gf('django.db.models.fields.related.OneToOneField')(to=orm['wagtailcore.Page'], unique=True, primary_key=True)),
 ('body', self.gf('wagtail.wagtailcore.fields.RichTextField')()),
 ('date', self.gf('django.db.models.fields.DateField')()),
 ))
 db.send_create_signal(u'wagweb', ['BlogPage'])

 

There’s BlogPage. Probably why BlogPage is working fine. But where’s my BlogIndexPage?

okay, time to make them migrate that:

[~/website/wagtailweb]# ./manage.py schemamigration wagweb --auto
 + Added model wagweb.BlogIndexPageRelatedLink
 + Added model wagweb.BlogIndexPage
Created 0002_auto__add_blogindexpagerelatedlink__add_blogindexpage.py. You can now apply this migration with: ./manage.py migrate wagweb

Boom!

Following which I will follow instructions and migrate again:

Running migrations for wagweb:
 - Migrating forwards to 0002_auto__add_blogindexpagerelatedlink__add_blogindexpage.
 > wagweb:0002_auto__add_blogindexpagerelatedlink__add_blogindexpage
 - Loading initial data for wagweb.
Installed 0 object(s) from 0 fixture(s)

Andd………?

 

IT WORKS!

bimo

I swear BMO is shouting DJANGO in her heart.

 

 

 

Advertisements

Migrations

Ain’t no flock of birds.

So if we’ve been following spapas’ tutorial on how to set-up Wagtail, we will also know how to do a syncdb and migrate

Now that my Wagtail dashboard is finally up, I can move on to the next step in the tutorial. Adding a blog page.

Bump! Migration draws up Not Synced (use migrations) on my wagtails and taggit. But running the usual manage.py migrate returns

— nothing to migrate

Solution:

1. Use schemamigrate

2. Wait patiently for changes to catch up?

SCHEMAMIGRATE

This means I’d use South to handle the migration. Like in this answer by running

python manage.py schemamigration --initial wagweb

This returns:

The error was: table "wagweb_blogpage" already exists
 ! Error found during real run of migration! Aborting.
! Since you have a database that does not support running
 ! schema-altering statements in transactions, we have had 
 ! to leave it in an interim state between migrations.

 

This means I shouldn’t be using South for migration in this format since Wagtail is already handling that.

Despite this error, I have now refreshed my Wagtail dashboard again and notice that my blogpage template is indeed in!

Maybe I should use solution #2.