Add DefaultVarbinaryColumnDefinition and use it.

Change-Id: I0129b95a2b969dd2305d8da57dc1f87601797a77
Make ColumnDefinition#sqlForColumnType() protected.

Change-Id: I91a998910514aa4c4420ef08af2fc993a62fac25
Simpilfy calls to ColumnDefinition#sqlForColumnType().

Change-Id: Icf1bcae4874b4462b3453d18020ec7f2abd3db63
Rename ColumnDefinition#sqlForColumnType() to be more accurate.

Rename the method to optionallyAddLimitToDataType() so its name is
more accurate and more descriptive on what the method does.

Change-Id: Ibd730b81996e3e4b36418414f457ee1e20ffd625
DB specific ColumnDefinitions extend defaults when possible.

Instead of having database specific ColumnDefinition sublcasses extend
ColumnDefinition and mix in the same traits that the default
ColumnDefinition subclasses do, have the database specific
ColumnDefinition sublcasses extend the corresponding default
ColumnDefinition subclass when possible.

The only time this doesn't work is when the database specific data
type has less capabilities than the assumptions that the default
ColumnDefinition subclass makes.

Change-Id: Ic62699bbdd32c8bab970276392522987c7d2d455
Derby's TIMESTAMP data type does not support a size specifier.

Change-Id: I879eeb39832381859cdf16e49879b50f9cfb2ba4
Make all Default*ColumnDefinition#sql def instead of val.

Now that database specific ColumnDefinition subclasses sometimes
extend default ColumnDefinition subclasses, change all 'val sql' to
'def sql' in the default subclasses to avoid initializing a data
member.

This makes all the #sql in the defaut subclasses consistent with other
ones that were already a def, e.g. DefaultTimestampColumnDefinition.

Change-Id: I82085cfb3cb387b7aafaaad5aa1b0bc4bf7ec56e
Make {Oracle,Postgresql}*ColumnDefinition#sql def instead of val.

Change-Id: I1e62b67f1fee4f6d1ba107298b085218aa6435f5
Make a 'val sql' a String and not a java.lang.StringBuilder.

Change-Id: I65b217dd7c79ba99f4d0baa7322fe9afc5b013b6
Rename all java.lang.StringBuilder instances from sql to sb.

Change-Id: I47a3a50c20636832159f6af77065abed5627aaf1
Correct exception message thrown from Migration#removeCheck().

Change-Id: I463a1a19afcc27f96a63ba9d088dbb62ad7a792b
Migration#grant() doc fix on the table_name parameter.

Change-Id: I7da9a5f2d90cc376de698f494f9bf562dd43cb9b
Fix DatabaseAdapter#newColumnDefinition()'s redefinition check.

In checking for a redefinition of the character set, the previously
seen CharacterSet was being compared with a CharacterSetName.

Change-Id: Ia6c52fd194ef4a9facf7ba251856ac33e04b06ab
Rename "set" to "charset" in "set @ CharacterSet" to match type.

Change-Id: Idd912f9686c92fcd33e43c94314489fd710eeee0
Support databases using different quote characters.

MySQL uses the backtick, '`', as the identifier quote character [1]
unless the ANSI_QUOTES SQL mode is enabled, in which case identifiers
can be quoted with double quotes.  However, to maintain native MySQL
compatibility without setting SQL modes, Scala Migrations will use the
backtick character.

Add support for different quote characters by adding a new abstract
val to DatabaseAdapter that specifies the quote character to use.

[1] https://dev.mysql.com/doc/refman/5.5/en/identifiers.html

Change-Id: I96762dc29d8cacb187c0153449679b3bbd11d34f
Support DBs with differing SQL to drop foreign key constraints.

For example, Derby, Oracle and PostgreSQL use

  ALTER TABLE child DROP CONSTRAINT idx_child_pk_parent;
                         ^^^^^^^^^^
while MySQL uses

  ALTER TABLE child DROP FOREIGN KEY idx_child_pk_parent;
                         ^^^^^^^^^^^

Change-Id: Ic44fa3a32ff2a40620b36f11fee3717492564a5d
Support MySQL which doesn't have table and column constraints.

According to the MySQL manual [1] in the ALTER TABLE clause: "The
CHECK clause is parsed but ignored by all storage engines."
Additionally, MySQL cannot parse CHECK clauses that Derby and
PostgreSQL can:

- Not being able to name the column constraint:

  CREATE TABLE person (age INT CONSTRAINT c CHECK (age >= 0));

  ERROR 1064 (42000): You have an error in your SQL syntax; check the
  manual that corresponds to your MySQL server version for the right
  syntax to use near 'CONSTRAINT c CHECK (age >= 0))' at line 1

- Not being able to list multiple CHECK clauses:

  CREATE TABLE person (age INT CHECK (age >= 0) CHECK (age < 200));

  ERROR 1064 (42000): You have an error in your SQL syntax; check the
  manual that corresponds to your MySQL server version for the right
  syntax to use near 'CHECK (age < 200))' at line 1

One solution is to still generate SQL for column check constraints by
not naming them and assuming that users will not list multiple CHECK
clauses in a single column SQL, preferring to put all the logic in a
single CHECK clause.  However, MySQL fails to parse the SQL to drop
the constraint

  mysql> ALTER TABLE person DROP CONSTRAINT chk;

  ERROR 1064 (42000): You have an error in your SQL syntax; check the
  manual that corresponds to your MySQL server version for the right
  syntax to use near 'CONSTRAINT chk' at line 1

So add to DatabaseAdapter a supportsCheckConstraints abstract val that
specifies if the database supports check constraints.

[1] https://dev.mysql.com/doc/refman/5.5/en/alter-table.html

Change-Id: I084776f90176ba0995bac8fcbbaf5555f75694ab
Extend the concept of a user to permit MySQL style accounts.

MySQL accounts consist of a user name followed by a host name,
e.g. 'foobar'@'localhost', where the host name is always required and
the user name and host name are separately quoted [1].  The quoting
requirement breaks the existing code which would quote the entire user
name, e.g. 'foobar@localhost', which would be interpreted as
'foobar@localhost'@'%'.

Goals for this commit:

1) To support Migration's grant() and revoke() methods that accept
   string user names so that a migration can be used for the currently
   supported Derby, Oracle and PostgreSQL databases along with MySQL
   in a future commit.

2) To properly quote a user name for inclusion in a SQL statement.

The only complication is that to support Derby, Oracle and PostgreSQL
with plan user names, the DatabaseAdapter needs to be able to convert
a plain string to a User object, which is provided by a UserFactory
instance.

Add these classes:

  - User, a sealed abstract class that declares a single abstract
    quoted() method which returns the user appropriately quoted for
    inclusion in a SQL statement.
  - PlainUser, a concrete User subclass used by Derby, Oracle and
    PostgreSQL.
  - UserFactory, an abstract class with an abstract nameToUser()
    method.

Add these objects:

  - User with apply(), a function to create a PlainUser.
  - PlainUserFactory with nameToUser(), a concrete UserFactory to
    create PlainUser instances.

Changes to DatabaseAdapter:

  - add an abstract val named userFactory returning a UserFactory.
  - change grantRevokeCommon(), grantSql() and revokeSql() to take
    Array[User] instead of Array[String].

Changes to Migration:

  - add two more grant() overloaded methods that take Array[User] and
    User.
  - add two more revoke() overloaded methods that take Array[User] and
    User.

[1] http://dev.mysql.com/doc/refman/5.5/en/account-names.html

Change-Id: Iec1bf8aa72cf9e49932a6788ac0803526416aa04
Document the Unicode case object for different databases.

Change-Id: I793f77634710e24de166d5fe75c835973c899102
Add support for character sets having a collation.

See MySQL's documentation on character set collations [1] which this
commit was written for.

- Add to the CharacterSet case class an optional collation name.
- Add a CharacterSet object that implements overloaded apply() to make
  it easier to create CharacterSet instances with or without a
  specified collation.
- In the Derby, Oracle and PostgreSQL database adapters, update
  pattern matches and any warnings on CharacterSet's new optional
  collation name.

[1] http://dev.mysql.com/doc/refman/5.5/en/charset-general.html

Change-Id: I4f96277cce801704f9363627f88ab17bd5316223