I recommend you to set your own names for migration files, it will turn it
easy to migrate.

db_define_table('tablename',Field('...'), migrate='mycustomname.table')
--
Bruno Rocha
[ About me: http://zerp.ly/rochacbruno ]



On Fri, May 20, 2011 at 2:01 AM, james c. <[email protected]> wrote:

> thanks Anthony for the quick reply. regards, james c.
>
> On May 19, 9:26 pm, Anthony <[email protected]> wrote:
> > You can read more about all this here:
> http://web2py.com/book/default/chapter/06#Migrations
> >
> >
> >
> >
> >
> >
> >
> > On Friday, May 20, 2011 12:25:03 AM UTC-4, Anthony wrote:
> > > On Thursday, May 19, 2011 11:48:07 PM UTC-4, james c. wrote:
> >
> > >> The tables are created by web2py
> > >> with a 31 digit hex number appended to the generic name + user id.
> >
> > > The table names in the actual database are simply the names you define
> in
> > > your db.define_table() definitions. If you want to drop a table, just
> use
> > > the table name itself (without any 31 digit hex number):
> >
> > > this_current_view = 'current_view_' + str(auth.user_id)
> > > db[this_current_view].drop()
> >
> > > The files with the 31 digit hex prefixes are not the database tables
> > > themselves -- they are web2py migration files that store migration data
> for
> > > the tables. The hex prefix is a hash of the db connection string.
> Looking at
> > > the DAL code, you should be able to figure out the prefix using this
> code:
> >
> > > import hashlib
> > > hex_prefix = '%s_%s.table' % (hashlib.md5(db._uri).hexdigest(),
> tablename)
> >
> > > However, the migration file names are simply an automatic default
> generated
> > > by web2py. As an alternative, you can specify your own migration file
> name
> > > for each table using the 'migrate' argument to define_table(). For
> example:
> >
> > > db.define_table(current_view_db, current_view_template,
> migrate='%s.table'
> > > % current_view_db)
> >
> > > Note, when you drop a table using .drop(), it drops it from the
> database,
> > > but I don't think it will delete the migration file, so you'll have to
> add
> > > some code to delete the migration file yourself.
> >
> > > Anthony
>

Reply via email to