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

Tests for invalid SQL for MySQL schema_diff #76

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions t/30sqlt-new-diff-mysql.t
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ ALTER TABLE new_name ADD COLUMN new_field integer NULL;

ALTER TABLE person ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1;

ALTER TABLE foobar CHANGE COLUMN name name varchar(255) NULL;

ALTER TABLE person CHANGE COLUMN person_id person_id integer(11) NOT NULL auto_increment;

ALTER TABLE person CHANGE COLUMN name name varchar(20) NOT NULL;
Expand Down Expand Up @@ -124,6 +126,8 @@ SET foreign_key_checks=1;

ALTER TABLE employee DROP COLUMN job_title;

ALTER TABLE foobar CHANGE COLUMN name name varchar(255) NULL;

ALTER TABLE old_name RENAME TO new_name,
ADD COLUMN new_field integer NULL;

Expand Down Expand Up @@ -196,6 +200,8 @@ ALTER TABLE employee DROP FOREIGN KEY FK5302D47D93FE702E,
DROP COLUMN job_title,
ADD CONSTRAINT FK5302D47D93FE702E_diff FOREIGN KEY (employee_id) REFERENCES person (person_id);

ALTER TABLE foobar CHANGE COLUMN name name varchar(255) NULL;

ALTER TABLE person DROP INDEX UC_age_name,
DROP INDEX u_name,
ADD COLUMN is_rock_star tinyint(4) NULL DEFAULT 1,
Expand Down
27 changes: 27 additions & 0 deletions t/data/diff/create1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@
schema:
procedures: {}
tables:
foobar:
fields:
id:
data_type: int
default_value: ~
extra: {}
is_auto_increment: 1
is_nullable: 0
is_primary_key: 1
name: id
order: 1
size:
- 11
name:
data_type: varchar
default_value: ~
extra: {}
is_nullable: 1
is_primary_key: 0
name: name
order: 2
size:
- 25
indices: []
name: foobar
options: []
order: 5
deleted:
constraints:
- fields: id
Expand Down
27 changes: 27 additions & 0 deletions t/data/diff/create2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,33 @@
schema:
procedures: {}
tables:
foobar:
fields:
id:
data_type: int
default_value: ~
extra: {}
is_auto_increment: 1
is_nullable: 0
is_primary_key: 1
name: id
order: 1
size:
- 11
name:
data_type: varchar
default_value: ~
extra: {}
is_nullable: 1
is_primary_key: 0
name: name
order: 2
size:
- 255
indices: []
name: foobar
options: []
order: 5
added:
constraints: []
fields:
Expand Down
6 changes: 6 additions & 0 deletions t/data/mysql/create.sql
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,9 @@ create table employee (
create table deleted (
id integer
);

CREATE TABLE foobar (
id int(11) NOT NULL auto_increment,
name varchar(25) default NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
5 changes: 5 additions & 0 deletions t/data/mysql/create2.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,8 @@ create table added (
id integer
);

CREATE TABLE foobar (
id integer NOT NULL auto_increment,
name varchar(255) default NULL,
PRIMARY KEY (id)
);