schema_migrations already exists

203 views
Skip to first unread message

Thiebo

unread,
Apr 1, 2022, 3:31:55 AM4/1/22
to Rodauth
Hi,


I put the migration for the app account in a directory and file called
./migrations/0001202204010824_auth.rb

I run the app account migration with this command :

sequel -m migrations postgres://copro_development@localhost/copro_development

That works fine. And then I put the migration for the ph account in a directory and file called
./migrations/0002202204010828_ph.rb

and run :

sequel -m migrations postgres://copro_development_password@localhost/copro_development

This runs into an error :

Error: Sequel::DatabaseError: PG::DuplicateTable: ERROR: relation « schema_migrations » already exists.

What am I doing wrong?

Many thanks


Jeremy Evans

unread,
Apr 1, 2022, 10:51:48 AM4/1/22
to rod...@googlegroups.com
With MySQL, you have to use a separate migrations table for the password account migrations.  This isn't possible to do from the command line.  You need to create the Sequel::Database object manually, and then run:

 Sequel::Migrator.run(DB, 'password_account_migrations_directory', :table=>'schema_migrations_password')

Apologies, this should be documented better.  I'll try to update the README before the next release.

Thanks,
Jeremy

Thiebo

unread,
Apr 1, 2022, 11:30:42 AM4/1/22
to Rodauth
Thanks Jeremy,
I'm not using mysql, but postgresql though.

Jeremy Evans

unread,
Apr 1, 2022, 11:31:40 AM4/1/22
to rod...@googlegroups.com
After additionally review, the README has the correct information.  Your error is that you ran the first migration as the regular account user and not the password account user.  As the README states (http://rodauth.jeremyevans.net/rdoc/files/README_rdoc.html#label-MySQL+Database+Setup): "You should run all migrations as the ph account, and GRANT specific access to the app account as needed.".  Sorry for the confusion.

Thanks,
Jeremy

Jeremy Evans

unread,
Apr 1, 2022, 11:33:32 AM4/1/22
to rod...@googlegroups.com
On Fri, Apr 1, 2022 at 8:30 AM Thiebo <thiebald...@gmail.com> wrote:
Thanks Jeremy,
I'm not using mysql, but postgresql though.

Doh!  Sorry about that.  Then the information in my original email is correct, and you need to use a separate table for the password migration, with something like:

Sequel::Migrator.run(DB, 'password_account_migrations_directory', :table=>'schema_migrations_password')

Thanks,
Jeremy

Thiebo

unread,
Apr 1, 2022, 12:00:11 PM4/1/22
to Rodauth
My wrong !
Many thanks Jeremy.

May I ask another question, or is it better to open a new thread? Re: configure emails that rodauth sends?
Reply all
Reply to author
Forward
0 new messages