Browse Source

add script to autogen, it's a hack by creating/upgading a db, but works

Looks like this is the only way:
https://github.com/sqlalchemy/alembic/discussions/1086
main
John-Mark Gurney 2 years ago
parent
commit
712ceeca74
3 changed files with 25 additions and 3 deletions
  1. +1
    -1
      ui/medashare/alembic.ini
  2. +2
    -2
      ui/medashare/alembic/README
  3. +22
    -0
      ui/medashare/autogen.sh

+ 1
- 1
ui/medashare/alembic.ini View File

@@ -55,7 +55,7 @@ version_path_separator = os # Use os.pathsep. Default configuration used for ne
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = sqlite+pysqlite:///:memory:
sqlalchemy.url = sqlite+pysqlite:///autogen.db.sqlite3


[post_write_hooks]


+ 2
- 2
ui/medashare/alembic/README View File

@@ -3,9 +3,9 @@ New Version

To create a revision, update the ORM in medashare/orm.py.

Then run:
Then in the medashare directory, run:
```
alembic revision --autogenerate -m 'what you did'
./autogen.sh "message of what you did"
```

This will create a version file. Edit the version file to support the


+ 22
- 0
ui/medashare/autogen.sh View File

@@ -0,0 +1,22 @@
#
# Script to auto generate any orm changes.
#

if [ -z "$*" ]; then
echo "Provide the upgrade message as an argument."
exit 1
fi

set -e

# Make sure we start clean
rm -f autogen.db.sqlite3

# Upgrade the database to head
alembic upgrade head

# Autogenerate the migrations
alembic revision --autogenerate -m "$*"

# Clean up
rm -f autogen.db.sqlite3

Loading…
Cancel
Save