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

docs: for sql db migration to 1.1 recommend --fake-initial #2425

Merged
merged 1 commit into from
Feb 19, 2019

Conversation

ploxiln
Copy link
Contributor

@ploxiln ploxiln commented Feb 7, 2019

... and --run-syncdb should no longer be needed.

Initial migrations were created for all models just before 1.1.0
in d1912d4. Prior to that, some models did not have any
migrations (and no initial migration), so --run-syncdb was needed
to create tables for them. But now that they have initial migrations,
those migrations run because django knows they have never been
applied, and they fail because the tables already exist. The
--fake-initial option is designed for this situation: it considers
initial migrations already applied if the tables already exist.

fixes #2412
replaces #2126

conflicts with #2409 and this is a tiny change so I'd be fine with rebasing this after that lands

@ploxiln ploxiln force-pushed the migrate_fake_initial branch from 1eef2da to 6b0c9ae Compare February 7, 2019 08:33
@deniszh
Copy link
Member

deniszh commented Feb 7, 2019

@ploxiln : will it work for all Django versions? Even if we upgrading from Graphite 0.9.x and/or Django 1.4 ?
Because --run-syncdb was added because normal migrate command did nothing before...

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 7, 2019

--run-syncdb was needed before graphite-web 1.1, but with 1.1+ it should not be needed, even for databases originally created with graphite-web 0.9.x and older django. While figuring out #2412 also I tested making a new database from nothing, without --run-syncdb, and all tables were created (by initial migrations which are now present).

(Now --fake-initial may be needed only because --run-syncdb was used before, when it was needed.)

@deniszh
Copy link
Member

deniszh commented Feb 7, 2019

@ploxiln : maybe that should be mentioned in docs too? Could you please amend it? Thanks!

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 7, 2019

possibly worth mentioning: --fake-initial was added in django 1.8 and --run-syncdb was added in django 1.9
(according to https://docs.djangoproject.com/en/1.9/ref/django-admin/#migrate)

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 7, 2019

looks like, in django 1.8 and earlier, the behavior of --run-syncdb was unconditionally provided:

No arguments: All migrated apps have all of their migrations run, and all unmigrated apps are synchronized with the database

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 7, 2019

OK, I'll try adding a bit more to the docs about this

@piotr1212
Copy link
Member

I'm wondering all the time if we could automate this stuff on app startup? Just like Grafana does.

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 8, 2019

Let me know how that looks/sounds.

I'll squash commits before merge.

... and --run-syncdb should no longer be needed.

Initial migrations were created for all models just before 1.1.0
in d1912d4. Prior to that, some models did not have any
migrations (and no initial migration), so --run-syncdb was needed
to create tables for them. But now that they have initial migrations,
those migrations run because django knows they have never been
applied, and they fail because the tables already exist. The
--fake-initial option is designed for this situation: it considers
initial migrations already done if the tables already exist.
@ploxiln ploxiln force-pushed the migrate_fake_initial branch from 99594f5 to e32a4ca Compare February 8, 2019 08:10
@deniszh
Copy link
Member

deniszh commented Feb 8, 2019

For me, it looks great. Maybe I could ask @gwaldo to check?

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 8, 2019

Good idea - I think I figured this out, but I'm no django expert :)

@DanCech
Copy link
Member

DanCech commented Feb 8, 2019

Is there any harm in always recommending users specify --fake-initial, ie having it in the example command?

@ploxiln
Copy link
Contributor Author

ploxiln commented Feb 8, 2019

I don't think there would be any harm in always using --fake-initial.

It should be needed at most once, when migrating from < 1.1 to >= 1.1, and the two places that that I did not include --fake-initial in the example were about "setting up a new database" - so I guess I did not want to encourage "just type this even though it does not make sense".

@deniszh
Copy link
Member

deniszh commented Feb 19, 2019

OK, I'm merging this for now.

@deniszh deniszh merged commit 928affa into graphite-project:master Feb 19, 2019
deniszh added a commit that referenced this pull request Oct 23, 2019
…pr-2425_pr-2426_pr-2426_pr-2426_pr-2431_pr-2433_pr-2436_pr-2436_pr-2443_commit-91ed1c0b_pr-2450_pr-2450_pr-2451_pr-2452_pr-2452_pr-2462_pr-2462_pr-2463_pr-2464_pr-2464_pr-2466_pr-2467_

[1.1.x] set package long description (#2407) | fix dashboard graph metric list icon paths with URL_PREFIX (#2424) | docs: for sql db migration to 1.1 recommend --fake-initial (#2425) | add tag formatting docs (#2426) | Update tags.rst (#242
@ploxiln ploxiln deleted the migrate_fake_initial branch April 2, 2020 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: migration from 1.0 to 1.1 may need --fake-initial
4 participants