Reputation: 349
This question is about the usage pattern of flask-migrate when it comes time to deploy. To set up a server or a docker container with your application, you need to create the databases.
Typically as in https://github.com/miguelgrinberg/flasky, the migrations folder is in the root of the project. This makes sense, but it means that in production, the migrations folder is not available if you are pulling the flask application as an installed package.
Is the correct pattern to copy the migrations folder to the container and run an upgrade there, or something else entirely? This seems awkward, because I would have to keep migrations in sync with the version of the app that I'm pulling from the python package repo. I am aware that it is possible to forego migrations entirely and just do db.create_all()
, but if that is the answer, then I may be confused about the purpose of db migrations.
Upvotes: 0
Views: 1426
Reputation: 12762
You can include files into a package with two-step:
1.set include_package_data
to True
in setup.py
:
from setuptools import find_packages, setup
setup(
name='myapp',
version='1.0.0',
packages=find_packages(),
include_package_data=True, # <--
zip_safe=False,
install_requires=[
'flask',
],
)
2.Include the file pattern in MANIFEST.in
:
graft myapp/static
graft myapp/templates
graft migrations # <--
This files will be included when you build the package. See here for the full MANIFEST.in
command available.
Upvotes: 3