New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migration for Table creation #174
Comments
New classes should be generated automatically if you increase the database version number, either through Configuration or AA_DB_VERSION meta-data. If your class is not a direct ancestor of model, it might be a bug in one of the new features. |
I somewhat lost overview of the codebase in the recent development boom, but originally the tables were created only when creating the database. For any subsequent versions you had to write a conversion/migration script. I'd say as long as it is a valid SQL, AA will not mind. :) However, bear in mind that the foreign keys are not supported in earlier android versions (API < 11 if I'm not mistaken), so if the script runs on such android version, you'll have problems. |
The documentation states: "If new classes are added, ActiveAndroid will automatically add them to the database". And I’m pretty shuere it works on my (old) codebase. Foreign keys should best be left to AA, as it decides itself whether to use them or not. |
Yes, you're right, I did a quick check of the codebase and it really should be adding the tables. It's probably a bug then. |
Damn, it's my fault, I thought that the version number should only change when a migration with column changes to already existing tables is added, not when adding models (tables), which in hindsight was a pretty dumb assumption. But I'm really intrigued as to where the tables get created, I couldn't find it in the code base. :S Thanks! |
I am trying to add new table to my db, i created new class (extends Model) and icnreased db version in Manifest but it seems that active android didn't create new table... i get no such table exception when trying to work with that table... Can you confirm that activeAndroid automatically creates new tables without creating migration scripts as it says in documentation... is it tested well |
I believe you have to bump up the database version number in your manifest file for the new table to be created. |
as i said i did that multiple times... nothing happens
|
my bad... i didnt put meta data tags into right place in manifest, sorry guys |
Hi, I have a problem where a new class is not generating the table it needs. What I want to do to fix it is to create a migration that creates the table. I have been reading Active Android's source trying to find the place you create the tables, but I haven't been able to find it.
I am fine with the basic type columns, but I don't know how to create the columns that reference other objects, mainly because I don't know how the foreign keys are created in ActiveAndroid. What my migration has right now is
The class represented by this is
The
Dispatch
column has a foreign key to theId
column of theDispatches
table. How is ActiveAndroid generating those foreign keys so I can recreate it as close to how it should be?Thanks and best regards,
The text was updated successfully, but these errors were encountered: