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
|
The migrations that I have created so far create the tables ok, but fail to put indexes on the columns where the model indicates properties should be indexed.
Do migrations support the adding of indexes? |
|
|
"Indexed" in the designer indicates that the field should be part of the full-text index -- i.e. it's an instruction to LightSpeed when building full-text indexes, not part of the database schema. See IndexedAttribute in the help for more info. Migrations don't currently support specifying database indexes. It's something we'd like to do, though, and I've logged a feature request for it. |
|
|
Is there anything new on indexes and migrations? Any plans on when it will be available? |
|
|
No unfortunately there have been no changes to this since Ivans earlier post, so currently you will still need to create your index using ExecuteNativeCommand and specifying the appropriate SQL for the creation of your index. At this stage we dont have any plans to make any improvements to this in the short term.
|
|
|
Would it theoretically be possible to write fields with indexes as custom attributes and take that into consideration when performing migration? Is migration extendable enough to do this (including knowing on which database index is to be created so that a suitable command can be send). Is migration performed using only the lightspeed model or also needs some other information written in .cs file or somewhere else? What exactly can migration do? Unique keys? Foreign keys? Other constraints? Views? Synonyms? Is it possible to handle errors when converting varchar(50) to varchar(30) like taking only the substring? What types can it convert? I am interested in this because I am coming from Delphi world where we developed a solution for schema migration that was capable of quite powerful synchronization. And I must say I am surprised there is no powerful solution for .NET environment. |
|
|
No there is no real extensibility in the framework currently other than you can extend the generated code as required and we provide the ExecuteNativeCommand call as a SQL escape hatch to allow arbitrary commands to be added in to a migration. The focus with the migration framework in LightSpeed is to allow you to script designer changes through code so you can migrate forward and backward without having to manually maintain database scripts, to that end the framework only offers up functions which mirror the changes that the designer would perform (e.g. adding a table, dropping a table, adding a column, dropping a column). It is not intended to be a database administration tool so we have not added in index management or the like as this is not something we offer in the designer either at present. Have a look through the documentation here for more details about the functions: http://www.mindscapehq.com/documentation/lightspeed/Database-Migrations/Creating-Migrations and here for the docs on the migrations more generally: http://www.mindscapehq.com/documentation/lightspeed/Database-Migrations It does not handle database level errors automatically - as with the designer it just passes these back up but there is some opportunity to do this in your migration code if you wish by simply wrapping the individual migration calls with exception handling code.
|
|
|
Although as Jeremy says this is not built into migrations, and you must use ExecuteNativeCommand to apply the index, there is an extensibility mechanism in the designer which would allow you to mark a field as indexed and to generate the appropriate ExecuteNativeCommand calls for indexed fields. This is not currently documented but I can post details if you think that could be useful to you. |
|