No project description provided
Project description
guillotina_evolution
Addon that provides evolutions/migrations to create or update objects in your Guillotina containers.
Install
pip install guillotina_evolution
Configure
Add the following values in app_settings
:
app_settings = {
"applications": [
"guillotina_evolution",
],
"commands": {
"g-evolve": "guillotina_evolution.commands.evolve.EvolveCommand",
},
Configure your app addon to initialize guillotina_evolution when is installed:
from guillotina.component import get_utility
from guillotina_evolution.interfaces import IEvolutionUtility
@configure.addon(name="app", title="Your guillotina app")
class ManageAddon(Addon):
@classmethod
async def install(cls, container, request):
utility = get_utility(IEvolutionUtility)
utility.install() # initialize current generation with the greatest registered generation
# ...
Write your evolver
Create a folder evolutions
inside your guillotina app that contains the following files:
app/evolutions/__init__.py
from .r20190118 import * # noqa
# Don't forget to add all rXXXXXXXX.py!
app/evolutions/r20190118.py
from guillotina_evolution.utils import register_evolution
@register_evolution(1)
async def evolver(container):
async for item in container.async_items():
item.title = item.title + ' (Migrated)'
item.register()
Update the includeme()
of your app:
app/__init__.py
def includeme(root):
# ...
configure.scan("app.evolutions")
Evolve
Run guillotina command g-evolve
to run your migrations.
g -c config.yaml g-evolve
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
guillotina_evolution-1.1.1.tar.gz
(16.9 kB
view hashes)
Close
Hashes for guillotina_evolution-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a5b341a87c0e06d4ad4e5778e4419f87b91f78ecd165edb0590d459992321c7 |
|
MD5 | 1f44948ca249fb54dee343d87ce4eb0f |
|
BLAKE2b-256 | 7c95e766a649ffd4a74e1dfd4389670e72f7acdf7ccc2d49d986aeb57f957ace |