Wow, sorry for answering myself, but I managed to get it working. I've 
tried to add c8b1837fhj47blahblahblah_ before newtable.table file and now 
everything is working.

Could it be a problem add this to my table file?

On Sunday, April 13, 2014 11:49:17 PM UTC+2, Wonton wrote:
>
> Hello!
>
> I have a web2py application with a sqlite database. The structure of my 
> db.py file is something like this:
>
> db = DAL('sqlite://storage.sqlite', migrate=False)
> ...
> db.define_table('table1',
> Field('field1'),
> Field('field2'))
> db.executesql('CREATE INDEX IF NOT EXISTS table1_field1 ON table1 
> (field1)')
>
> db.define_table('table2',
> Field('field1'),
> Field('field2'))
> db.executesql('CREATE INDEX IF NOT EXISTS table2_field1 ON table2 
> (field1)')
>
> ...
>
> Each time I want to add a new table or a new field, I remove ", 
> migrate=False", make the change and, after it has been applied I add ", 
> migrate=False" again.
> This has been working very well so far.
>
> Inside my database folder I have this files:
> storage.sqlite
> c8b1837fhj47blahblahblah_table1.table
> c8b1837fhj47blahblahblah_table2.table
>
> Well, now my problem. Last time I made an update (I added a new table) in 
> my database, the migration was broken. I don't know why but I guess it was 
> probably because I removed accidentally the .table files and after restore 
> them maybe they were too old. I tried everything and finally the migration 
> worked and the database added the new table.
>
> Now my db.py file is something like this:
>
> db = DAL('sqlite://storage.sqlite', migrate=False)
> ...
> db.define_table('table1',
> Field('field1'),
> Field('field2'))
> db.executesql('CREATE INDEX IF NOT EXISTS table1_field1 ON table1 
> (field1)')
>
> db.define_table('table2',
> Field('field1'),
> Field('field2'))
> db.executesql('CREATE INDEX IF NOT EXISTS table2_field1 ON table2 
> (field1)')
>
> db.define_table('newtable',
> Field('field1'))
> db.executesql('CREATE INDEX IF NOT EXISTS newtable_field1 ON newtable 
> (field1)')
>
> ...
>
> but the first strange thing, in my database folder now I have this:
> storage.sqlite
> c8b1837fhj47blahblahblah_table1.table
> c8b1837fhj47blahblahblah_table2.table
> newtable.table
>
> Why newtable.table doesn't have the c8b1837fhj47blahblahblah part? Is this 
> important?
>
> The thing is that I need to add a new field to table1 table and I'm 
> getting errors and I don't know how to solve them.
>
> Just removing the ", migrate=False" part I get the error "newtable is 
> already defined" and the application fails.
> I've tried to use db = DAL('sqlite://storage.sqlite', fake_migrate=True)and 
> have no errors. Then I add my new field but no changes are applied to 
> the database.
>
> What am i doing wrong? how could I fix this?
>
> Kind regards and thank you very much!
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to