Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » Automatic Upgrade MySQL schema
Automatic Upgrade MySQL schema [message #37368] Fri, 28 September 2012 04:48 Go to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

I discover,that MySQL automatic schema upgrade is not work normally on Mysql server ver 5.5.

I propose this change to Package Sql, file SqlSchema.cpp
(added Rows 25-28)

			if(dialect == MSSQL) {
				Upgrade() << Expand("alter table @t add ") << cn << ";\n";
				Upgrade() << Expand("alter table @t alter column ") << cd << ";\n";
			} 
			else if(dialect == MY_SQL) 						//Added
				Upgrade() << Expand("alter table @t add ") << cn << ";\n";	//Added
				Upgrade() << Expand("alter table @t modify ") << cd << ";\n";	//Added
			}									//Added

			else if (dialect == SQLITE3)
				Upgrade() << Expand("alter table @t add ") << cd << ";\n";



SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Automatic Upgrade MySQL schema [message #37418 is a reply to message #37368] Tue, 02 October 2012 08:00 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
A according to

http://dev.mysql.com/doc/refman/5.5/en/alter-table-examples. html

it looks like "modify" line is not really necessary, the only problem is that the 'generic' code (originally meant for Oracle) adds parenthesis around the column, is that correct?

For now, I will just merge it with Sqlite3... Please check whether it has helped.

Mirek
Re: Automatic Upgrade MySQL schema [message #37423 is a reply to message #37418] Tue, 02 October 2012 12:25 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

This link say, that ALTER COMMAND will have format:

ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);

There is nothing to say that instead of CHANGE (or MODIFY), you can leave just ADD.

pls comment.

PS
In any case, after the addition of the patch on the server MySQL 5.5 all start working.


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Automatic Upgrade MySQL schema [message #37424 is a reply to message #37423] Tue, 02 October 2012 12:40 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Upgrade schema, in its current state, is not meant to change column types (which is sort of unusual operation anyway and not all DBs support it easily in all cases), but only to add new columns.

That way, I believe this part of examples is relevant:

Quote:


To add a new TIMESTAMP column named d:

ALTER TABLE t2 ADD d TIMESTAMP;



Mirke
Re: Automatic Upgrade MySQL schema [message #37425 is a reply to message #37424] Tue, 02 October 2012 12:56 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

Smile But with this path We can modify column types.

What way to do this optionally ( very need )?


SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Automatic Upgrade MySQL schema [message #37426 is a reply to message #37425] Tue, 02 October 2012 14:21 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Ok, I see. I just wanted to preserve uniform behavior for all DBs.

OTOH, it is true that this is extension, so why not. Patch applied.

mirek
Re: Automatic Upgrade MySQL schema [message #37429 is a reply to message #37426] Wed, 03 October 2012 10:35 Go to previous messageGo to next message
sergeynikitin is currently offline  sergeynikitin
Messages: 748
Registered: January 2008
Location: Moscow, Russia
Contributor

May be changing the type of the type column is not so much the undesirable effect and it can allow for other databases? Smile

SergeyNikitin<U++>( linux, wine )
{
    under( Ubuntu || Debian || Raspbian );
}
Re: Automatic Upgrade MySQL schema [message #37430 is a reply to message #37429] Wed, 03 October 2012 12:41 Go to previous message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
sergeynikitin wrote on Wed, 03 October 2012 04:35

May be changing the type of the type column is not so much the undesirable effect and it can allow for other databases? Smile


If only all of them supported this feature...
Previous Topic: XmlNode and text
Next Topic: List DSN in ODBC
Goto Forum:
  


Current Time: Thu Apr 18 13:35:27 CEST 2024

Total time taken to generate the page: 0.01357 seconds