Use etlalchemy for the migration

This commit is contained in:
coolneng 2021-02-10 01:26:54 +01:00
parent 95850dc4f8
commit 388814bb3f
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
2 changed files with 32 additions and 3 deletions

25
migration.py Normal file
View File

@ -0,0 +1,25 @@
from etlalchemy import ETLAlchemySource, ETLAlchemyTarget
source = ETLAlchemySource(
"sqlite:///databases/odyfo.db",
included_tables=[
"users",
"cities",
"games",
"payments",
"player_availabilities",
"player_cancel_games",
"purchase_games",
"sports",
"teams",
"user_ratings",
"venue_images",
"venues",
"web_bookings",
],
)
target = ETLAlchemyTarget(
"postgresql+psycopg2://postgres@localhost/odyfo", drop_database=True
)
target.addSource(source)
target.migrate()

View File

@ -8,7 +8,7 @@ let
origin = "databases/odyfo.db";
in mkShell {
buildInputs = [ postgresql sqlite ];
buildInputs = [ postgresql python27 python27Packages.virtualenv ];
shellHook = ''
trap "kill 0" EXIT
@ -23,10 +23,14 @@ in mkShell {
pg_ctl start -o "--unix_socket_directories=${data_dir} --listen_addresses='''"
fi
psql -d postgres -f ${sql_file}
alias psql='psql -d postgres'
alias nuke='rm -rf ${data_dir}'
# Workaround to use pip
SOURCE_DATE_EPOCH=$(date +%s)
virtualenv .venv
export PATH=$PWD/.venv/bin:$PATH
pip install etlalchemy
pip install psycopg2
'';
}