web2py app on startup trying to create a duplicate table auth_user

46 views
Skip to first unread message

james c.

unread,
Apr 18, 2021, 1:35:05 AM4/18/21
to web2py-users
db = DAL(myconf.get('db.uri'),
auto_import = True,
ignore_field_case = True,
entity_quoting = False,
pool_size = 10
migrate = True,
migrate_enabled = True,
check_reserved = ['common'],
lazy_tables = False)

. . .

auth = Auth(db, host_names=myconf.get('host.names'))

auth.settings.extra_fields['auth_user'] = [
Field('organization', length=128, label=T('Organization')),
Field('address', length=128, label=T('Street Address'), requires=[IS_NOT_EMPTY()]),
Field('city', length=64, label=T('City'), requires=[IS_NOT_EMPTY()]),
Field('statename', length=64, label=T('State'), requires=[IS_NOT_EMPTY()]),
Field('zip', length=8, label=T('Zip Code'),
requires=[IS_MATCH(r'^\d{5}(-\d{4})?$', error_message='not a zip code')]),
Field('phone', length=16, label=T('Phone Number'), requires=[IS_LENGTH(16, 10)])]


auth.define_tables(username=True, signature=True)  <--- fails here

"""
This application was developed on windows, The application is now on ubuntu 16.04. The database exist and this code, as it is above, is trying to create a table, auth_user, that already exists. When migrate=True, this is not suppose to happen - but it is. The table auth_user" already exists and the code fails at auth.define_tables(username=True, signature=True), with the following message: 
DuplicateTable: relation "auth_user" already exists

Thanks in advance, any recommendations appreciated, James

james c.

unread,
Apr 18, 2021, 2:30:27 AM4/18/21
to web2py-users
And the solution is to add fake_migrate=True into the DAL statement and the auth.define_tables statement.
Reply all
Reply to author
Forward
0 new messages