I want all my auth_tables in a specific schema in PostgreSQL: wos_2019_1.
I have created a model like this:
db.define_table('auth_user',
Field('id','id',
represent=lambda id:SPAN(id,' ',A('view',_href=URL('auth_user_read',args=id)))),
Field('username', type='string',
label='Username'),
Field('first_name', type='string',
label='First Name'),
Field('last_name', type='string',
label='Last Name'),
Field('email', type='string',
label='Email'),
Field('password', type='password',
readable=False,
label='Password'),
Field('created_on','datetime',default=datetime.datetime.today(),
label='Created On',writable=False,readable=False),
Field('modified_on','datetime',default=datetime.datetime.today(),
label='Modified On',writable=False,readable=False,
update=datetime.datetime.today()),
Field('registration_key',default='',
writable=False,readable=False),
Field('reset_password_key',default='',
writable=False,readable=False),
Field('registration_id', length=64, default=lambda:str(uuid.uuid4()),
writable=False,readable=False),
format='%(username)s')
db.auth_user._rname = 'wos_2019_1.auth_user'
db.auth_user.first_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty)
db.auth_user.last_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty)
db.auth_user.password.requires = CRYPT(key=auth.settings.hmac_key)
db.auth_user.username.requires = IS_NOT_IN_DB(db, db.auth_user.username)
db.auth_user.registration_id.requires = IS_NOT_IN_DB(db, db.auth_user.registration_id)
db.auth_user.email.requires = (IS_EMAIL(error_message=auth.messages.invalid_email),
IS_NOT_IN_DB(db, db.auth_user.email))
# auth.settings.extra_fields['auth_user'] = []
auth.define_tables(username=True, signature=True, migrate = True)
# e-pos van Anthony op web2py-lys
lt = db._LAZY_TABLES
[lt[t][2].update(rname='wos_2019_1.%s' % t) for t in db.tables if t.startswith('auth')]
But still I get:
Traceback (most recent call last):
File "/home/js/py4web/py4web/core.py", line 677, in import_apps
module_name, init).load_module()
File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 907, in load_module
File "<frozen importlib._bootstrap_external>", line 732, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 696, in _load
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "apps/wos_2019_1/__init__.py", line 2, in <module>
from . models import db
File "apps/wos_2019_1/models.py", line 50, in <module>
db.auth_user._rname = 'wos_2019_1.auth_user'
File "/usr/local/lib/python3.7/dist-packages/pydal/base.py", line 675, in __getattr__
return self.lazy_define_table(tablename, *fields, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pydal/base.py", line 627, in lazy_define_table
polymodel=polymodel)
File "/usr/local/lib/python3.7/dist-packages/pydal/adapters/base.py", line 798, in create_table
return self.migrator.create_table(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pydal/migrator.py", line 282, in create_table
self.adapter.create_sequence_and_triggers(query, table)
File "/usr/local/lib/python3.7/dist-packages/pydal/adapters/base.py", line 881, in create_sequence_and_triggers
self.execute(query)
File "/usr/local/lib/python3.7/dist-packages/pydal/adapters/__init__.py", line 67, in wrap
return f(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pydal/adapters/base.py", line 413, in execute
rv = self.cursor.execute(command, *args[1:], **kwargs)
psycopg2.errors.DuplicateTable: relation "auth_user" already exists
In the past the recipe used above did work with web2py.
How do I convince py4web to put those tables where I want it?
I have checked: there are no auth_* tables in the wos_2019_1-schema.
Regards
Johann