PostgreSQL conflicts with tables already existing when model code is run

14 views
Skip to first unread message

jlegler

unread,
Feb 17, 2009, 7:03:56 PM2/17/09
to web2py Web Framework
I've been developing a webapp against sqlite and in the process of
moving it to postgresql for production I have run into some problems.
This is the latest one:

When using postgresql, web2py is complaining that tables defined in my
model already exist.
For example, when I call:

auth.define_tables()

I get an error saying:

ProgrammingError: relation "auth_user" already exists.

If I put an if statement on that function call, it simply moves down
the file to the next table definition and throws a similar error. Why
is this happening in postgresql and not sqlite? I am seriously
considering trying out mysql. Is anyone out there using postgresql
successfully?

jlegler

unread,
Feb 17, 2009, 7:09:42 PM2/17/09
to web2py Web Framework
Oops, should have searched the forum before posting. It looks like I
just need to put migrate-False in my table definitions. However, that
does prompt a follow up question.

If I use migrate=False in each of my tables and then modify my tables
at a future date, will it update the tables or just ignore them?

-jason

jlegler

unread,
Feb 17, 2009, 7:12:24 PM2/17/09
to web2py Web Framework
Actually, looking at the web2py manual, I shouldn't have to specify
migrate=False. If the table exists and corresponds to the definition,
it should do nothing. Anyone know why this is not the case when using
postgresql?

-jason

mdipierro

unread,
Feb 17, 2009, 11:43:26 PM2/17/09
to web2py Web Framework
If the tables were not created by web2py you need migrate = False.

Massimo

jlegler

unread,
Feb 18, 2009, 1:58:39 AM2/18/09
to web2py Web Framework
They were created by web2py though. How does web2py determine if
something was created by it? Is there a best practice way to update
the apps I create so that this doesn't happen?
Reply all
Reply to author
Forward
0 new messages