Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#56 fixed headings hierarchy + some additional documentation
- Loading branch information
Showing
49 changed files
with
180 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
##### | ||
Howto | ||
##### | ||
|
||
This is mainly for me to remember how to do things 😁. | ||
|
||
**************** | ||
Database Changes | ||
**************** | ||
|
||
Migration with Restore from Backup | ||
================================== | ||
|
||
Sometimes it's not possible to do database changes via a Django migration. | ||
For example if you try to split up a model inheriting from Wagtails page | ||
model, it's not possible to add / remove pages via a Django Migration | ||
because you don't have access to the Page model in a migration | ||
(only the database). | ||
|
||
Atm the best option for me is to copy the production database locally, | ||
do the migration in a notebook and then backup the migrated database and | ||
restore it in production. A manual migration is only needed for a database | ||
where there are models which should be added to the new model. | ||
|
||
Steps | ||
----- | ||
|
||
#. Backup old production database | ||
#. Fetch production database and restore it to the local development database | ||
#. Set site to localhost in wagtailadmin | ||
#. Migrate the database structure | ||
#. Add a new model inheriting from the old one and prefix the attributes you want to keep with `new_` | ||
#. Create a new migration | ||
#. Use `flit install -s` to install the `django-cast <https://github.com/ephes/django-cast>`_. package in the venv of your application | ||
#. Migrate | ||
#. Migrate the database data manually | ||
#. Use a jupyter notebook to copy the old models over to the new model [example]_ | ||
#. Make sure to prefix uniqe page fields like `slug` with `new` first and rename it afterwards | ||
#. Remove the moved attributes from the old model | ||
#. Rename the attributes prefixed with `new_` in the new model | ||
#. Dump local database and restore to production | ||
#. Change site back to `python-podcast.staging.wersdoerfer.de` with port `443` | ||
#. `pg_dump python_podcast | gzip > backups/db.staging.psql.gz` | ||
#. `cd deploy && ansible-playbook restore_database.yml --limit staging` | ||
|
||
|
||
.. [example] blog_to_podcast example | ||
.. code-block:: python | ||
def blog_to_podcast(blog, content_type): | ||
exclude = {"id", "page_ptr_id", "page_ptr", "translation_key"} | ||
kwargs = { | ||
f.name: getattr(blog, f.name) | ||
for f in Blog._meta.fields | ||
if f.name not in exclude | ||
} | ||
kwargs["slug"] = f"new_{blog.slug}" | ||
kwargs["content_type"] = content_type | ||
kwargs["new_itunes_artwork"] = blog.itunes_artwork | ||
kwargs["new_itunes_categories"] = blog.itunes_categories | ||
kwargs["new_keywords"] = blog.keywords | ||
kwargs["new_explicit"] = blog.explicit | ||
return Podcast(**kwargs) | ||
# first migration to add podcast model | ||
from django.core.management import call_command | ||
call_command("migrate") | ||
# get the original blog + parent | ||
original_slug = "show" | ||
blog = Blog.objects.get(slug=original_slug) | ||
blog_parent = Page.objects.parent_of(blog).first() | ||
# fix hostname and port | ||
site = Site.objects.first() | ||
site.hostname = "localhost" | ||
site.port = 8000 | ||
site.save() | ||
# create new page | ||
podcast_content_type = ContentType.objects.get(app_label="cast", model="podcast") | ||
podcast = blog_to_podcast(blog, podcast_content_type) | ||
podcast = blog_parent.add_child(instance=podcast) | ||
# fix treebeard, dunno why this is needed | ||
from django.core.management import call_command | ||
call_command("fixtree") | ||
podcast = Podcast.objects.get(slug=f"new_{origninal_slug}") # super important! | ||
# move children - this is extremely brittle! | ||
from wagtail.actions.move_page import MovePageAction | ||
for child in blog.get_children(): | ||
mpa = MovePageAction(child, podcast, pos="last-child") | ||
mpa.execute() | ||
# delete old page | ||
blog.delete() | ||
# restore slug | ||
podcast.slug = original_slug | ||
podcast.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
************ | ||
Installation | ||
============ | ||
************ | ||
|
||
This is just a dummy for now. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*************** | ||
Release Process | ||
=============== | ||
*************** | ||
|
||
Bump Version Number | ||
------------------- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.0 (2018-11-05) | ||
++++++++++++++++++ | ||
------------------ | ||
|
||
* First release on PyPI. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.1 (2018-11-07) | ||
++++++++++++++++++ | ||
------------------ | ||
|
||
* Travis build is ok. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.11 (2019-03-21) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Fixed requirements for package |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.12 (2019-03-22) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Improved installation documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.13 (2019-03-22) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Release to update read the docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.14 (2019-03-23) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Added rtfd configuration file to be able to use python 3 :/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.15 (2019-03-23) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Trying again... rtfd still failing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.16 (2019-03-23) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Finally, rtfd is working again, including screencast |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0.1.18 (2019-04-18) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Fixed broken update view due to empty chaptermarks + test | ||
* Fixed two image/video javascript bugs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0.1.2 (2018-11-08) | ||
++++++++++++++++++ | ||
------------------ | ||
|
||
* Added some requirements | ||
* Release Documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0.1.20 (2019-04-24) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Fixed version history | ||
* Better release docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0.1.21 (2019-04-24) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Fixed package dependencies | ||
* Better release docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0.1.25 (2019-05-23) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Bugfix: i18n should now work, finally | ||
* Bugfix: Allow empty chaptermarks text field + test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.26 (2019-05-23) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Bugfix: i18n should now work, finally!!1 duh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.1.29 (2020-01-03) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* Use poetry instead of requirements.txt and setup.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
0.1.30 (2020-10-25) | ||
+++++++++++++++++++ | ||
------------------- | ||
|
||
* fixed some logfile parsing bug | ||
* tried to add wagtail but removed it again |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.1.31 (never released) | ||
+++++++++++++++++++++++ | ||
----------------------- | ||
|
||
* Trying to use vuepress for documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.1.32 (never released) | ||
+++++++++++++++++++++++ | ||
----------------------- | ||
|
||
* not clear |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.1.33 (never released) | ||
+++++++++++++++++++++++ | ||
----------------------- | ||
|
||
* dont know anymore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.1.34 (never released) | ||
+++++++++++++++++++++++ | ||
----------------------- | ||
|
||
* dont know anymore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
0.1.35 (2020-10-25) | ||
+++++++++++++++++++++++ | ||
------------------- | ||
|
||
* last package released that is based on `master` branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
0.1.4 (2018-11-18) | ||
++++++++++++++++++ | ||
------------------ | ||
|
||
* Include css via cast_base.html | ||
* audio fixes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
0.1.7 (2019-02-28) | ||
++++++++++++++++++ | ||
------------------ | ||
|
||
* forgot linting |
Oops, something went wrong.