Closed mrjbg closed 11 years ago
That is out of the scope for schema migrations but this is something you can achieve by overriding the generated migration class as described in the docs. I will paste a link when I am at my machine later.
Sent from Samsung Mobile
-------- Original message --------
From: mrjbg notifications@github.com
Date:
To: robotoworks/mechanoid mechanoid@noreply.github.com
Subject: [mechanoid] sqlite insert statements in .mechdb file supported? (#195)
Well the title says it all :)
Does mechanoid support plain sql insert statements like for example:
insert into mytable values(1, 'text', 3.0);
If not could you please add this feature?
The idea is that I want to have a pre-populated database in my app.
Thanks!
— Reply to this email directly or view it on GitHub.
Hi thanks for the reply. The problem with your solution is that it can get REALLY cumbersome if I have a pre-existing data with thousands of rows. If I can just paste the sql insert statements it would save me huge amounts of work.
Cheers!
Where would these thousands of rows come from? It might be best then to just add a plain text file with statements terminated by semicolon, parse it and exec each line as raw sql either before or after a migration wherever it makes sense.
Mechanoid will give you great value for schema migrations but for data migrations you should use an approach that is more efficient.
Sent from Samsung Mobile
-------- Original message --------
From: mrjbg notifications@github.com
Date:
To: robotoworks/mechanoid mechanoid@noreply.github.com
Cc: Ian Warwick fluxtah@hotmail.com
Subject: Re: [mechanoid] sqlite insert statements in .mechdb file supported? (#195)
Hi thanks for the reply. The problem with your suggestion is that it can get REALLY cumbersome if I have a pre-existing data with thousands of rows. If I can just paste the sql insert statements it would save me huge amounts of work.
Cheers!
— Reply to this email directly or view it on GitHub.
Whether I parse those sql statements from a text file or have them hard coded is actually irrelevant. The point is that I need to be able to raw-add (e.g. insert that data) into the sqlite database.
I saw where I could add those lines to the XYZDBOpenHelper, however this class is generated and adding code to classes that are generated is not a smart move. The next time mechanoid regenerates this class I will just loose my data, or if I have a backup I will have to add the raw sql insert statements again, which defeats the purpose of an automation tool.
Mechanoid has a generate once policy by default for user editable stubs (defaults to src folder), and a generate always policy for base code that you should not touch, abstracts, etc (defaults to src-gen).
In a nutshell editing any file in src by default your code is safe and Mechanoid will not regen on top of that.
Hope that makes sense.
Sent from Samsung Mobile
-------- Original message --------
From: mrjbg notifications@github.com
Date:
To: robotoworks/mechanoid mechanoid@noreply.github.com
Cc: Ian Warwick fluxtah@hotmail.com
Subject: Re: [mechanoid] sqlite insert statements in .mechdb file supported? (#195)
Whether I parse those sql statements from a text file or have them hard coded is actually irrelevant. The point is that I need to be able to raw-add (e.g. insert that data) into the sqlite database.
I saw where I could add those lines to the XYZDBOpenHelper, however this class is generated and adding code to classes that are generated is not a smart move. The next time mechanoid regenerates this class I will just loose my data, or if I have a backup I will have to add the raw sql insert statements again, which defeats the purpose of an automation tool.
— Reply to this email directly or view it on GitHub.
Closing this issue since there are no plans to support DML statements in migrations.
Well the title says it all :)
Does mechanoid support plain sql insert statements like for example:
insert into mytable values(1, 'text', 3.0);
If not could you please add this feature?
The idea is that I want to have a pre-populated database in my app.
Thanks!