Here are the relevant parts of the model. I didn't copy the
boilerplate code like connection string, etc at the start of the db.py
file:
# Common fields.
###############################################################
# Web data.
__web_resource = db.Table(db,
'__web_resource',
Field('wikipedia_id'),
Field('myspace_id'),
Field('facebook_id'))
# All tables will inherit this simple audit.
current_user_id = (auth.user and auth.user.id) or 1
__audit = db.Table(db,
'__audit',
Field('created_on', 'datetime',
default=request.now),
Field('created_by', db.auth_user,
default=current_user_id),
Field('modified_on', 'datetime',
default=request.now),
Field('modified_by', db.auth_user,
default=current_user_id))
# Each table's corresponding *audit table will inherit this audit.
__audit_trail = db.Table(db,
'__audit_trail',
Field('modified_on', 'datetime',
default=request.now),
Field('modified_by', db.auth_user,
default=current_user_id))
# Tables.
######################################################################
# Performer
__performer = db.Table(db,
'__performer',
Field('name'),
Field('slug'),
Field('twitter_id'),
Field('musicbrainz_guid'), # the offending new
field
__web_resource)
db.define_table('performer', __performer, __audit)
db.define_table('performer_audit_trail', __performer, __audit_trail)
On Apr 24, 10:46 am, mdipierro <[email protected]> wrote:
> hmmm. I guess I need to the model then. fake_migrate was supported in
> 1.76.5
>
> Massimo
>
> On Apr 24, 9:37 am, Matthew <[email protected]> wrote:
>
> > 1.76.5
>
> > On Apr 24, 10:35 am, mdipierro <[email protected]> wrote:
>
> > > you must have a very old web2py version.
>
> > > On Apr 24, 9:25 am, Matthew <[email protected]> wrote:
>
> > > > I'm including previously-defined tables in other tables to reduce
> > > > maintenance. For example, I have "__web_resource" table that has
> > > > Wikipedia IDs, etc that I'm using in other tables.
>
> > > > When I tried your suggestion, I got the following error:
>
> > > > File "/home/matthew/dev/projects/webapp/src/app/applications/myapp/
> > > > models/db.py", line 114, in <module>
> > > > __web_resource, fake_migrate=True)
> > > > TypeError: __init__() got an unexpected keyword argument
> > > > 'fake_migrate'
>
> > > > Is this due to the inclusion of other tables?
>
> > > > On Apr 23, 10:13 am, mdipierro <[email protected]> wrote:
>
> > > > > Something went wrong with migration. Do this:
>
> > > > > 1) comment the field that gives you problem and set migrate to fake:
>
> > > > > db.define_table('performer',
> > > > > ...
> > > > > # Field('musicbrainz_guid'....),
> > > > > ...,
> > > > > fake_migrate=True) # <<<
>
> > > > > 2) run appadmin once (it should work)
>
> > > > > 3) uncomment field and remove fake migrate
>
> > > > > db.define_table('performer',
> > > > > ...
> > > > > Field('musicbrainz_guid'....),
> > > > > ...)
>
> > > > > 4) run appadmin again. If you get an error something is wrong in your
> > > > > model.
>
> > > > > On Apr 23, 6:19 am, Matthew <[email protected]> wrote:
>
> > > > > > >>> perf = db(db.performer.id > 0).first()
>
> > > > > > Traceback (most recent call last):
> > > > > > File "<console>", line 1, in <module>
> > > > > > AttributeError: 'Set' object has no attribute 'first'>>> perf =
> > > > > > db(db.performer.id > 0).select().first()
>
> > > > > > Traceback (most recent call last):
> > > > > > File "<console>", line 1, in <module>
> > > > > > File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py",
> > > > > > line
> > > > > > 3056, in select
> > > > > > rows = response(query)
> > > > > > File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py",
> > > > > > line
> > > > > > 3051, in response
> > > > > > db._execute(query)
> > > > > > File "/home/matthew/dev/projects/webapp/src/app/gluon/sql.py",
> > > > > > line
> > > > > > 958, in <lambda>
> > > > > > self._execute = lambda *a, **b: self._cursor.execute(*a, **b)
> > > > > > ProgrammingError: column performer.musicbrainz_guid does not exist
> > > > > > LINE 1: ..._id, performer.facebook_id, performer.twitter_id,
> > > > > > performer....
>
> > > > > > On Apr 22, 8:48 am, Kuba Kucharski <[email protected]> wrote:
>
> > > > > > > Can you show us the line with a query code?
>
> > > > > > > --
> > > > > > > Kuba
>
> > > > > > > --
> > > > > > > Subscription
> > > > > > > settings:http://groups.google.com/group/web2py/subscribe?hl=en