[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: RFC: script to run sqlalchemy migrations on the db



Toshio Kuratomi wrote:

app2 $ migrate-runner -h db2 -d fas2 /usr/share/fas/database
This script must create a temporary db user, fas2temp on db2.
That user will have permission to modify anything in the fas2 database.
If you stop this script in the middle of running you will want to remove the created user from the db.
To continue, enter your password for sudo on db2:

Running: ssh db2 pg_temp_user --verbose --create fas2
pg_temp_user: checking for db fas2... yes
  [sudo -u postgres psql select from pg_users where name = 'fas2temp']
pg_temp_user: checking for existing fas2temp... no
[if yes, then abort and have the admin remove the account, check for other issues, etc]
pg_temp_user: generating password... success
pg_temp_user: create fas2temp... success
[sudo -u postgres cat temppasswdfile | sudo -u postgres createuser fas2temp -P -E && sudo -u postgres rm temppasswdfile || sudo -u postgres rm temppasswdfile]
pg_temp_user: setting fas2temp permissions on fas2
   [echo "grant all on fas2 to fas2temp" | sudo -u postgres psql fas2]
   [print fas2temp passwd to stdout which migrate-runner captures]
Received password for fas2temp
Running migrate
   [various script invocations that loupgaroublond helps me create]
Running: ssh db2 pg_temp_user --verbose --remove fas2
pg_temp_user: checking for db fas2... yes
pg_temp_user: checking for existing fas2temp... yes

[One more step needed here:]
pg_temp_user: updating table ownership to postgres... success
[This detects all the tables in the fas2 db and reassigns ownership from the fas2temp user to the database superuser.]

pg_temp_user: removing fas2temp... success
Successfully upgraded database

-Toshio



Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]