having to use migrate=false after migrating the database

37 views
Skip to first unread message

Vlad

unread,
Jul 17, 2022, 1:06:26 AM7/17/22
to web2py-users
I've been using PythonAnywhere Postgres hosting for a while. Used pg_dump and pg_restore to recreate the database in ElephantSQL.
Not sure if this has contributed to the problem, but had to use options that drop owner and privileges (otherwise pg_restore generated errors, complaining about non-existing roles etc.)
In the end, everything works perfectly except that I must use migrate=false option only.
If migrate=true - it attempts to recreate all the tables and, obviously, complains that tables already exist - because they do exist.
Greatly appreciate suggestions on how to fix this.

A side question on efficiency: visually I notice that PythonAnywhere postgres hosting works quicker (but ElephantSQL is theoretically better hosting). Is it because in PA both app and db run "in close proximity", presumably on the same server?

Massimiliano

unread,
Jul 17, 2022, 5:42:11 AM7/17/22
to web...@googlegroups.com
You can try fake_migrate=True so that DAL recreates tables metafata files in the database folder.
Once done, you can restore fake_migrate=False and migrate=True.

Should work

--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups "web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/abcae64b-e9b3-4d30-9ae7-98ff01cb51ban%40googlegroups.com.


--
Massimiliano

Vlad

unread,
Jul 17, 2022, 11:17:47 AM7/17/22
to web2py-users
Massimiliano, thank you for the suggestion.

I tried fake_migrate=True - it works fine, but then I switched it back to migrate=True  , and it crashed again.
(migrate=False works perfectly.)

Any ideas?

Massimiliano

unread,
Jul 17, 2022, 11:31:16 AM7/17/22
to web...@googlegroups.com
Should be

migrate = True
fake_migrate = True
db = DAL(db_uri, migrate=migrate, fake_migrate=fake_migrate)

And after one run, that recreate metadata files in databases folder:

migrate = True
fake_migrate = False
db = DAL(db_uri, migrate=migrate, fake_migrate=fake_migrate)

maybe you can also check your databases folder permissions. Web2py needs to be able to write into.



--
Massimiliano

Eliezer (Vlad) Tseytkin

unread,
Jul 18, 2022, 9:22:44 AM7/18/22
to web...@googlegroups.com
I am not familiar with "databases folder permissions" - where can I look this up, the way web2py uses them so that I would be able to ask elephantsql customer support about it?

It seems strange to me: when I start from an empty database - everything works like a charm, the way it has to.
but when I pg_dump and pg_restore the database from elsewhere (seems to restore everything correctly) - this is where problems start: migrate=True attempts to recreate the existing tables; migrate=False works perfectly fine (and fake_migrate worked by itself, but didn't help to fix the issue...)



You received this message because you are subscribed to a topic in the Google Groups "web2py-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/web2py/xb6DXxF-HdQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to web2py+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/CANPTPxJ5R_ocbegJTeY2otBQYea5ctLmdww3yzed4zVszESRzA%40mail.gmail.com.

Massimiliano

unread,
Jul 18, 2022, 12:36:21 PM7/18/22
to web...@googlegroups.com
Hello Vlad,

Sorry for the misunderstanding,

‘database’ or ‘databases’ I don’t remember is a folder inside you web2py applications directory.

~/web2py/applications/yourapplication/database

Inside of that DAL keeps metadata informations about the tables managed.

I was referring to the filesystem permissions for that folder. 




Eliezer (Vlad) Tseytkin

unread,
Jul 18, 2022, 12:49:26 PM7/18/22
to web...@googlegroups.com
Ah, that doesn't change - permissions are good - I am using the same app, just switching the database provider, so that's not a problem. Only pointing to a different db.



Reply all
Reply to author
Forward
0 new messages