-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to check singletenant to mtn migration.
- Loading branch information
1 parent
48c0ae7
commit a5908dd
Showing
1 changed file
with
92 additions
and
0 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
.github/workflows/singletenant-to-multitenant-migration.yml
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,92 @@ | ||
name: Singletenant to Multitenant Migration | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- develop | ||
|
||
pull_request: # TODO: remove this trigger before merging the PR | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
services: | ||
postgres: | ||
image: postgres:12-alpine | ||
env: | ||
POSTGRES_USER: postgres | ||
POSTGRES_DB: postgres | ||
POSTGRES_PASSWORD: postgres | ||
PGHOST: localhost | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
env: | ||
PGHOST: localhost | ||
PGPORT: 5432 | ||
PGUSER: postgres | ||
PGPASSWORD: postgres | ||
PGDATABASE: postgres | ||
DATABASE_URL: postgres://postgres:postgres@localhost:5432/postgres?sslmode=disable | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: 1.22.1 | ||
cache: true | ||
cache-dependency-path: go.sum | ||
|
||
- name: Install PostgreSQL Client | ||
run: sudo apt-get update && sudo apt-get install -y postgresql-client | ||
|
||
- name: Wait for PostgreSQL to be ready | ||
run: | | ||
until pg_isready; do | ||
echo "Waiting for postgres container..." | ||
sleep 2 | ||
done | ||
- name: Load Database Dump | ||
run: psql -d $DATABASE_URL -f .github/resources/single_tenant_dump.sql | ||
|
||
- name: Run Go migrations | ||
run: | | ||
go run main.go db admin migrate up | ||
go run main.go db tss migrate up | ||
- name: Execute migration function | ||
run: | | ||
psql -d ${DATABASE_URL} -c "SELECT admin.migrate_tenant_data_from_v1_to_v2('migrated_tenant');" | ||
- name: Execute cleanup queries | ||
run: | | ||
psql -d ${DATABASE_URL} -c " | ||
BEGIN TRANSACTION; | ||
DROP TABLE public.messages CASCADE; | ||
DROP TABLE public.payments CASCADE; | ||
DROP TABLE public.disbursements CASCADE; | ||
DROP TABLE public.receiver_verifications CASCADE; | ||
DROP TABLE public.receiver_wallets CASCADE; | ||
DROP TABLE public.auth_user_password_reset CASCADE; | ||
DROP TABLE public.auth_user_mfa_codes CASCADE; | ||
DROP TABLE public.receivers CASCADE; | ||
DROP TABLE public.auth_users CASCADE; | ||
DROP TABLE public.wallets_assets CASCADE; | ||
DROP TABLE public.assets CASCADE; | ||
DROP TABLE public.wallets CASCADE; | ||
DROP TABLE public.organizations CASCADE; | ||
DROP TABLE public.gorp_migrations CASCADE; | ||
DROP TABLE public.auth_migrations CASCADE; | ||
DROP TABLE public.countries CASCADE; | ||
DROP TABLE public.submitter_transactions CASCADE; | ||
DROP TABLE public.channel_accounts CASCADE; | ||
COMMIT;" |