Skip to content
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

Support more datatypes & better identity_insert #75

Open
wants to merge 17 commits into
base: master
Choose a base branch
from

Conversation

jordanclark
Copy link
Collaborator

Added new limit options for integers, dates, & money (maps to decimal on non-mssql db)
handy new methods mediumInteger(), smallInteger(), tinyInteger()

adds support for MSSQL: DATE, SMALLDATETIME, MONEY, SMALLMONEY, BIGINT, SMALLINT, TINYINT

adds support for mysql: BIGINT UNSIGNED, BIGINT, INT UNSIGNED, MEDIUMINT UNSIGNED, MEDIUMINT, SMALLINT UNSIGNED, SMALLINT, TINYINT UNSIGNED, TINYINT

Improve the IDENTITY_INSERT feature added for SQL Server.

I've moved building SQL INSERT into the abstract adapter, this way the custom adapters can extend the code if necessary instead of just a prefix/suffix method.

For the Microsoft SQL adapter I check if any column being inserted into is an IDENTITY column, and then wrap the IDENTITY_INSERT code when necessary, before it would only work if your identity column happened to be named "id".

I also improved the $getColumnDefinition function which wasn't using the "pattern" argument to only return a single column instead of the whole database.

I modified $getColumnDefinition so it uses the wheels $dbinfo tag and also passes in the "pattern" argument so that it only returns a single column, instead of the whole table.
I moved most of the SQL building code from migration.cfc to /adapters/abstract.cfc
This allows the adapter to add any special handling, which at this point is primarily to support SQL Server Identity Insert correctly
Moved addRecord from migration.cfc to here, then adapters can override or extend the SQL INSERT 
Added $getIdentityColumn which gives the name of the "identity" column on the table. This is necessary because an identity column doesn't have to be the primary key.

Extending abstract's addRecord method, this now checks for trying to insert a value into any "identity" column, not just one named "id".

Removed addRecordPrefix & addRecordSuffix
added new limit options for integers, dates, & money (maps to decimal on non-mssql db)
handy new methods mediumInteger(), smallInteger(), tinyInteger()

adds support for MSSQL: DATE, SMALLDATETIME, MONEY, SMALLMONEY, BIGINT, SMALLINT, TINYINT

adds support for mysql: BIGINT UNSIGNED, BIGINT, INT UNSIGNED, MEDIUMINT UNSIGNED, MEDIUMINT, SMALLINT UNSIGNED, SMALLINT, TINYINT UNSIGNED, TINYINT
@tdm00
Copy link
Owner

tdm00 commented Mar 29, 2013

@jordanclark thanks for this substantial contribution. I'll make some time to merge the diff into a new topic branch to test. Would you have any migration files that you could share to help test this functionality? I'm trying to create a set of these to test each change that I implement as it's the only way I've found to do testing. If you could add them to the tests folder push back up here they should be added to this merge request

@jordanclark
Copy link
Collaborator Author

You were correct the latest changes are part of the pull request, I'm a git-noob but at least I'm learning.

Here are 3 test migrations, I hope that helps.

@tdm00
Copy link
Owner

tdm00 commented Apr 1, 2013

Jordan,

Please don't apologize, even though I've been using Git for two years I'm
constantly learning new things myself. Try a "git add -p" sometime to see
the latest thing I've learned. In addition to that Github does a few
things beyond what Git does by itself, such as pull-requests and how
they're updated, again no apology needed. Thank you for these
contributions and I hope to get them included this week.

On Sun, Mar 31, 2013 at 10:46 PM, jordanclark [email protected]:

You were correct the latest changes are part of the pull request, I'm a
git-noob but at least I'm learning.

Here are 3 test migrations, I hope that helps.


Reply to this email directly or view it on GitHubhttps://github.com//pull/75#issuecomment-15702407
.

Troy Murray

…mns (only currently supports MSSQL & MySQL)

Add CHAR() column type for fixed length columns
MSSQL: CHAR, NCHAR, NVARCHAR, NTEXT
MYSQL: Character encoding for char, string & text
Oracle: CHAR
PostgreSQL: CHARACTER
(resolves andybellenie's issue tdm00#57)
… allow overriding.

Added NULL support to addRecord/updateRecord.
Added automatic timestamp support for createdAt/updatedAt and soft-delete deletedAt
…Instead the quoteTableName() method is the perfect place to force lower case for mysql, and let the other adapters decide what they want to do in their own quoteTableName().

Apparently postgress & oracle don't require quoting names, because if you do the name becomes case-sensitive, so now those adapters check if the name needs to be quoted instead of always doing it.

Also fixes issue tdm00#43 for quoting postgres table names.
@tdm00
Copy link
Owner

tdm00 commented Apr 16, 2013

@jordanclark I haven't forgotten about this pull request. I tried merging it with a new topic branch last week and it broke the plugins ability to load the migrations. I'm working on trying to find out why as it must be working for you.

@jordanclark
Copy link
Collaborator Author

@tdm00 Troy sorry about that bug, I also created a fix for railo 4 and createObjectFromRoot and incorrectly transfered the code into the plugin. It should be working correctly now.

@tdm00
Copy link
Owner

tdm00 commented Apr 26, 2013

Jordan,

I tried merging this after you sent it and the plugin stopped working. I
haven't been able to track it own, or rather had the time. I'll give this a
try, thanks for letting me know.

On Friday, April 26, 2013, jordanclark wrote:

@tdm00 https://github.com/tdm00 Troy sorry about that bug, I also
created a fix for railo 4 and createObjectFromRoot and incorrectly
transfered the code into the plugin. It should be working correctly now.


Reply to this email directly or view it on GitHubhttps://github.com//pull/75#issuecomment-17091823
.

Troy Murray

@jordanclark
Copy link
Collaborator Author

Ping?

@tdm00
Copy link
Owner

tdm00 commented Jul 4, 2013

Jordan,

The last time I tried the merge on the master branch it still wasn't
producing an error that I haven't been able to track down.

On Thu, Jul 4, 2013 at 6:46 PM, jordanclark [email protected]:

Ping?


Reply to this email directly or view it on GitHubhttps://github.com//pull/75#issuecomment-20495618
.

Troy Murray

@jordanclark
Copy link
Collaborator Author

I have been using my updated version of the plugin without a problem for
months. I did just fix a little bug I caused in the MicrosoftSQLServer
adapter, but I don't think that would have affected you.

Were you using it with Railo? Because there is an unrelated bug in the
latest version of Railo that is still incompatible with CFWheels, a patch I
submitted to the wheels team hasn't gone anywhere either, but I applied the
same fix to dbmigrate's copy of $createObjectFromRoot, but now it checks
wheel's version number so it shouldn't break previous builds.

Maybe give it another shot?

Jordan

On Thu, Jul 4, 2013 at 3:51 PM, Troy Murray [email protected]:

Jordan,

The last time I tried the merge on the master branch it still wasn't
producing an error that I haven't been able to track down.

On Thu, Jul 4, 2013 at 6:46 PM, jordanclark [email protected]:

Ping?


Reply to this email directly or view it on GitHub<
https://github.com/tdm00/cfwheels-dbmigrate-plugin/pull/75#issuecomment-20495618>

.

Troy Murray


Reply to this email directly or view it on GitHubhttps://github.com//pull/75#issuecomment-20495691
.

@tdm00
Copy link
Owner

tdm00 commented Jul 5, 2013

Sure, I'll give it a try tonight.

On Friday, July 5, 2013, jordanclark wrote:

I have been using my updated version of the plugin without a problem for
months. I did just fix a little bug I caused in the MicrosoftSQLServer
adapter, but I don't think that would have affected you.

Were you using it with Railo? Because there is an unrelated bug in the
latest version of Railo that is still incompatible with CFWheels, a patch
I
submitted to the wheels team hasn't gone anywhere either, but I applied
the
same fix to dbmigrate's copy of $createObjectFromRoot, but now it checks
wheel's version number so it shouldn't break previous builds.

Maybe give it another shot?

Jordan

On Thu, Jul 4, 2013 at 3:51 PM, Troy Murray <[email protected]<javascript:_e({}, 'cvml', '[email protected]');>>wrote:

Jordan,

The last time I tried the merge on the master branch it still wasn't
producing an error that I haven't been able to track down.

On Thu, Jul 4, 2013 at 6:46 PM, jordanclark <[email protected]<javascript:_e({}, 'cvml', '[email protected]');>>wrote:

Ping?


Reply to this email directly or view it on GitHub<

https://github.com/tdm00/cfwheels-dbmigrate-plugin/pull/75#issuecomment-20495618>

.

Troy Murray


Reply to this email directly or view it on GitHub<
https://github.com/tdm00/cfwheels-dbmigrate-plugin/pull/75#issuecomment-20495691>

.


Reply to this email directly or view it on GitHubhttps://github.com//pull/75#issuecomment-20532787
.

Troy Murray

- Support empty string defaults (it doesn't have to be null)
- Support SQL function defaults like GETDATE()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants