-
-
Notifications
You must be signed in to change notification settings - Fork 164
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
mssqldef: support index #126
Conversation
schema/generator.go
Outdated
ddls = append(ddls, fmt.Sprintf("ALTER TABLE %s DROP INDEX %s", g.escapeTableName(desired.table.name), g.escapeSQLName(currentIndex.name))) | ||
ddls = append(ddls, fmt.Sprintf("ALTER TABLE %s ADD %s", g.escapeTableName(desired.table.name), g.generateIndexDefinition(desiredIndex))) | ||
switch g.mode { | ||
case GeneratorModeMssql: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is applicable to all of your patches, but please consider NOT to introduce g.mode
to a place where g.mode
switch is not used. At least I couldn't understand why you needed to exclude areSameIndexOptions
from areSameIndexes
, and using a name like generateDDLForCreateIndex
only for mssql is pretty confusing while you already have generateIndexDefinition
for the same purpose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May I see your effort to fix the way you branch your code based on g.mode
as explained in the above comment and this comment first? Feel free to modify existing implementations for doing so.
I'm not saying you must not use g.mode
switch everywhere. The general idea is that you should use g.mode
switches preferably in deeply nested function calls rather than more abstract functions that already do a lot more things (e.g. generateDDLsForCreateTable
). For example, if you generate entire DDLs from generateIndexDefinition
, you could move a g.mode
switch from generateDDLsForCreateTable
to generateIndexDefinition
.
The reason why I'm suggesting these changes is that first of all, ideally, every g.mode
switch should be eliminated. But if you need to introduce it, you should consider introducing it to a trivial location that doesn't really impact an overall code flow or readability. As I said in the above comment, your current patch duplicates a function with similar roles, branches them in a relatively abstract place, and makes it hard to understand what is used by which mode.
Some of the existing codes don't follow the policy and they should be fixed at some point. But I don't want to newly introduce such places.
I knew you need |
I apologize for the lack of explanation of the changes I made.
The following are the reasons why I needed In mssql, I couldn't use the syntax As for As you pointed out, I think that |
Not sure why you re-posted the comment, but #126 (comment) was the answer to it. |
I changed the way to make a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thanks
This change supports the following features.