This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Is it possible to write pluggin generating custom part of migration (using ExecuteNativeCommand)? We have many problems such as http://www.mindscapehq.com/forums/thread/4037 so we want to generate our part of migration code durring "CreateMigrations" InstalSoft |
|
|
Can you elaborate on what you mean by writing a plugin? Do you mean something that would emit some custom code blocks into the generated migrator class file on generation?
|
|
|
Yes, exactly. Problem "Migration.AddColumn default value" I solved by introducing my own base Migration class for all generating migrations:
Actually the only thing to do is changing base class in generated code and we are satisfied with this solution. I will check if other problems connected with Sqlite (delete/rename colums) could be solved in the same method. |
|
|
I managed also with drop columns with SqLite. I used method 1) Rename actual table. 2) Create new table without droped column. 3) Copy data from old table to new one. 4) Drop old table. I do it in "protected override void DropColumn()" so I have one problem. If I drop more then one columns in one migration my code is inefficient. Could you add empty virtual methods "AfterUp" and "AfterDown" to Migration class? Then I could buffer droped columns and call my code only once. |
|
|
Yep we can do that - I have added BeforeUp/AfterUp and BeforeDown/AfterDown methods to the Migration class which will be triggered on execution by the Migrator and this will be updated in tonights nightly build for you.
|
|
|
Thank you very much! I have one additional question: Will AfterUp/AfterDown methods be called outside SQL transaction (or after run summary SQL migration)? For droping columns issue I have to use additional qsl connection (ExecuteNativeCommand does not return results) to obtain actual table scheme. If I do it when LightSpeed is in transaction(or before run SQL) I don't see actual migrations changes. |
|
|
Those calls themselves are run within the scope of the transaction being used to run the migration itself so any calls to ExecuteNativeCommand in the Before/After hooks will be executed within the transaction scope as well.
|
|