Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Table already exists in initial migration #129

Open
bodgerbarnett opened this issue Aug 1, 2017 · 4 comments
Open

Table already exists in initial migration #129

bodgerbarnett opened this issue Aug 1, 2017 · 4 comments

Comments

@bodgerbarnett
Copy link

I'm trying to upgrade an old codebase from Django 1.5 to 1.11.

Most things seem to be fine so far (!) but I have a problem when migrating from South.

When the initial migration for fluent_pages tries to run, it finds that it needs to create the HtmlPageTranslation table so it really does run that migration (rather than faking it) but the PageLayout table already exists and I get this error:-

django.db.utils.ProgrammingError: relation "fluent_pages_pagelayout" already exists

Any ideas how to fix this?

@vdboor
Copy link
Contributor

vdboor commented Aug 1, 2017

Latest state of Django replaces South with native Django migrations.

When you make such upgrade, please upgrade the project first to the last version of django-fluent-pages that supported south. This allows you to run the it's latest south migrations.

Then, on Django 1.11 you can use manage.py migrate --fake-initial. The first Django migration corresponds with the latest south migration. Then, new Django migrations can run upgrading your project further.

@bodgerbarnett
Copy link
Author

So I can't jump straight from 0.8.5 (my current version) to 1.1.1 ?
That seems a little odd to me.

I'm not that sure how Django deals with the process of creating the new initial migration for an app once support for South is removed but I'd kind of assumed that the only models that would appear in the initial migration file would be the same models that were in the initial South migration of the app.

That way, any user could upgrade through multiple versions of that app without having to upgrade them in steps like this?

If I've got this wrong - or if you can't fix the initial migration - can you let me know which specific version of fluent-pages I need to upgrade to first, before making the jump to the current version please?

Thanks.

@bodgerbarnett
Copy link
Author

Just to clarify on this one - if I upgrade my existing (Django 1.5) install to use version 1.0.1 (which looks like the latest South-supporting version of fluent-pages) and fully migrate up to that, then I should then be able to upgrade to version 1.1.1 (using Django 1.11) without the above problem - is that correct?

With that in mind, I tried upgrading to 1.0.1 and found that I needed to do a few things to make it work.

  1. I can no longer filter for slug in FluentPage so I've had to iterate through them all, testing each one's slug as I go.
  2. The ID of the ContentTypes that my fluent-contents Markdown items point to is different to the ID of the plugin that the code looks for to render that placeholder. I found this issue (MarkupItem plugin error during upgrade from 0.8.3 to 0.9 django-fluent-contents#37) which seemed to be a similar problem so I updated the polymorphic ctype for them all to point at the right ContentType. This seemed to work.

Am I right to do these things? It seems to work but I'm not sure if there will be any other effects or if I should have done this differently.

@vdboor
Copy link
Contributor

vdboor commented Nov 21, 2017

From what I've seen you managed to solve most issues, which is great! 👍

Yes, the upgrade path takes you through different steps. The difference is too big to perform a single upgrade. Consider it like upgrading a Windows 7 to 10 system, or a Mac 10.6 -> 10.13. It needs multiple steps because it's very hard to handle the differences otherwise.

  1. Filtering on the slug is no longer possible because it moved to a translation model. You can use Page.objects.translated(slug=...)
  2. That seems like a bug, but nice to see you've managed to fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants