forked from liquibase/liquibase-test-harness
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding support for mssql & spock-reports
- Loading branch information
1 parent
2033a7b
commit 51b706b
Showing
14 changed files
with
314 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ target/ | |
/.apt_generated/ | ||
/.apt_generated_tests/ | ||
bin/ | ||
build/ | ||
.project | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/main/resources/liquibase/harness/change/changelogs/mssql/addForeignKey.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> | ||
|
||
|
||
<changeSet id="1" author="kristyl"> | ||
<createTable tableName="countries" schemaName="lbcat2"> | ||
<column name="id" type="int"> | ||
<constraints primaryKey="true" nullable="false"/> | ||
</column> | ||
<column name="name" type="varchar(50)"/> | ||
</createTable> | ||
</changeSet> | ||
|
||
<changeSet id="2" author="kristyl"> | ||
<createTable tableName="person"> | ||
<column name="id" type="int" autoIncrement="true"> | ||
<constraints primaryKey="true" nullable="false"/> | ||
</column> | ||
</createTable> | ||
<addColumn tableName="person"> | ||
<column name="country_id" type="int"/> | ||
</addColumn> | ||
<addForeignKeyConstraint | ||
baseTableName="person" baseColumnNames="country_id" | ||
constraintName="fk_person_country" | ||
referencedTableName="countries" referencedTableSchemaName="lbcat2" referencedColumnNames="id" | ||
/> | ||
</changeSet> | ||
</databaseChangeLog> |
52 changes: 52 additions & 0 deletions
52
src/main/resources/liquibase/harness/change/changelogs/mssql/dropForeignKey.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<databaseChangeLog | ||
xmlns="http://www.liquibase.org/xml/ns/dbchangelog" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd"> | ||
|
||
<changeSet id="1" author="nvoxland"> | ||
<comment> | ||
You can add comments to changeSets. | ||
They can even be multiple lines if you would like. | ||
They aren't used to compute the changeSet MD5Sum, so you can update them whenever you want without causing problems. | ||
</comment> | ||
<createTable tableName="person"> | ||
<column name="id" type="int" autoIncrement="true"> | ||
<constraints primaryKey="true" nullable="false"/> | ||
</column> | ||
<column name="firstname" type="varchar(50)"/> | ||
<column name="lastname" type="varchar(50)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</createTable> | ||
</changeSet> | ||
<changeSet id="7" author="nvoxland"> | ||
<createTable tableName="company"> | ||
<column name="id" type="int" autoIncrement="true"> | ||
<constraints primaryKey="true" nullable="false"/> | ||
</column> | ||
<column name="name" type="varchar(50)"> | ||
<constraints nullable="false"/> | ||
</column> | ||
</createTable> | ||
</changeSet> | ||
<changeSet id="22" author="nvoxland"> | ||
<addColumn tableName="person"> | ||
<column name="employer_id" type="int"/> | ||
</addColumn> | ||
</changeSet> | ||
|
||
<changeSet id="23" author="nvoxland"> | ||
<addForeignKeyConstraint | ||
baseTableName="person" baseColumnNames="employer_id" | ||
constraintName="fk_person_employer" | ||
referencedTableName="company" referencedColumnNames="id" | ||
deleteCascade="true"/> | ||
</changeSet> | ||
|
||
<changeSet id="24" author="nvoxland"> | ||
<dropForeignKeyConstraint baseTableName="person" constraintName="fk_person_employer"/> | ||
<rollback/> | ||
</changeSet> | ||
</databaseChangeLog> |
16 changes: 16 additions & 0 deletions
16
src/main/resources/liquibase/harness/change/expectedSnapshot/mssql/addDefaultValue.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.Column": [ | ||
{ | ||
"column": { | ||
"defaultValue": "title_test", | ||
"defaultValueConstraintName": "DF_posts_title", | ||
"name": "title", | ||
"nullable": true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...in/resources/liquibase/harness/change/expectedSnapshot/mssql/addDefaultValueComputed.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.Column": [ | ||
{ | ||
"column": { | ||
"defaultValue": "getdate\\(\\)\\!\\{liquibase.statement.DatabaseFunction\\}", | ||
"defaultValueConstraintName": "DF_posts_inserted_date", | ||
"name": "inserted_date", | ||
"nullable": true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/resources/liquibase/harness/change/expectedSnapshot/mssql/addForeignKey.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.ForeignKey": [ | ||
{ | ||
"foreignKey": { | ||
"deferrable": false, | ||
"initiallyDeferred": false, | ||
"name": "fk_person_country" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/resources/liquibase/harness/change/expectedSnapshot/mssql/createView.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.View": [ | ||
{ | ||
"view": { | ||
"definition": " SELECT authors.id,\n authors.first_name,\n authors.last_name,\n authors.email\n FROM authors;", | ||
"name": "test_view" | ||
} | ||
}] | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/resources/liquibase/harness/change/expectedSnapshot/mssql/dropDefaultValue.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"snapshot": { | ||
"objects": { | ||
"liquibase.structure.core.Column": [ | ||
{ | ||
"column": { | ||
"name": "title", | ||
"nullable": true | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
src/main/resources/liquibase/harness/change/expectedSql/mssql/addDefaultValue.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ALTER TABLE posts ADD CONSTRAINT DF_posts_title DEFAULT 'title_test' FOR title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/usr/bin/env bash | ||
|
||
/opt/mssql/bin/sqlservr & | ||
|
||
echo "Waiting for server to start...." | ||
#do this in a loop because the timing for when the SQL instance is ready is indeterminate | ||
for i in {1..50}; | ||
do | ||
/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P ${SA_PASSWORD} -d master -i /docker-entrypoint-initdb.d/mssql-init.sql | ||
if [ $? -eq 0 ] | ||
then | ||
echo "mssql-init.sh completed" | ||
break | ||
else | ||
echo "not ready yet..." | ||
sleep 5 | ||
fi | ||
done | ||
|
||
sleep infinity |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
DECLARE @dataPath varchar(256); | ||
DECLARE @logPath varchar(256); | ||
SET @dataPath=(SELECT CAST(serverproperty('InstanceDefaultDataPath') AS varchar(256))); | ||
SET @logPath=(SELECT CAST(serverproperty('InstanceDefaultLogPath') AS varchar(256))); | ||
|
||
CREATE LOGIN [lbuser] with password=N'LiquibasePass1', CHECK_EXPIRATION=OFF; | ||
GO | ||
|
||
CREATE DATABASE lbcat; | ||
GO | ||
|
||
EXEC lbcat..sp_addsrvrolemember @loginame = N'lbuser', @rolename = N'sysadmin' | ||
GO | ||
|
||
/* By default, we set the compatibility level to the oldest version we are officially supporting. Note that there | ||
* are differences in behaviour, e.g. with implicit conversions of date and time values. See | ||
* https://docs.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql for details. | ||
*/ | ||
ALTER DATABASE [lbcat] SET COMPATIBILITY_LEVEL = 100 | ||
GO | ||
|
||
USE [lbcat] | ||
GO | ||
ALTER DATABASE [lbcat] MODIFY FILEGROUP [PRIMARY] DEFAULT | ||
GO | ||
ALTER DATABASE [lbcat] ADD FILEGROUP [liquibase2] | ||
GO | ||
|
||
DECLARE @dataPath varchar(256); | ||
DECLARE @logPath varchar(256); | ||
SET @dataPath=(SELECT CAST(serverproperty('InstanceDefaultDataPath') AS varchar(256))); | ||
SET @logPath=(SELECT CAST(serverproperty('InstanceDefaultLogPath') AS varchar(256))); | ||
|
||
DECLARE @createSql varchar(2000); | ||
SET @createSql = (SELECT 'ALTER DATABASE [lbcat] ADD FILE ( NAME = N''liquibase2'', FILENAME = N''' + @dataPath + 'liquibase2.ndf'' , SIZE = 8192KB , FILEGROWTH = 65536KB ) TO FILEGROUP [liquibase2]'); | ||
EXECUTE(@createSql); | ||
GO | ||
|
||
DROP TABLE IF EXISTS [dbo].[authors] | ||
GO | ||
|
||
CREATE TABLE [dbo].[authors]( | ||
[id] [int] NOT NULL, | ||
[first_name] [varchar](255) NOT NULL, | ||
[last_name] [varchar](255) NULL, | ||
[email] [varchar](255) NULL, | ||
[birthdate] [varchar](255) NULL, | ||
[added] [datetime] NOT NULL, | ||
CONSTRAINT [PK_PrimaryKey] PRIMARY KEY ([id]) | ||
) ON [PRIMARY] | ||
GO | ||
|
||
INSERT INTO [dbo].[authors] ([id],[first_name],[last_name],[email],[birthdate],[added]) | ||
VALUES ('1','Courtney','Hodkiewicz','[email protected]','1986-01-22','1983-08-23 14:55:09'), | ||
('2','Marielle','Kuhlman','[email protected]','1995-08-08','1984-03-05 01:25:02'), | ||
('3','Emmanuel','Gleichner','[email protected]','1997-05-09','1977-08-09 10:28:04'), | ||
('4','Hertha','Goodwin','[email protected]','2014-08-21','2009-01-28 11:02:56'), | ||
('5','Ewald','Sauer','[email protected]','1988-10-10','2000-11-02 00:37:53') | ||
GO | ||
|
||
DROP TABLE IF EXISTS [dbo].[posts] | ||
GO | ||
|
||
CREATE TABLE [dbo].[posts]( | ||
[id] [int] NOT NULL, | ||
[author_id] [varchar](255) NOT NULL, | ||
[title] [varchar](255) NULL, | ||
[description] [varchar](255) NULL, | ||
[content] [varchar](255) NULL, | ||
[inserted_date] [date] NULL | ||
) ON [PRIMARY] | ||
GO | ||
|
||
INSERT INTO [dbo].[posts] ([id],[author_id],[title],[description],[content],[inserted_date]) | ||
VALUES ('1','1','sit','in','At corporis est sint beatae beatae.','1996-05-04'), | ||
('2','2','nisi','et','Sunt nemo magni et tenetur debitis blanditiis.','2000-05-25'), | ||
('3','3','ratione','blanditiis','Ipsa distinctio doloremque et ut.','1997-09-22'), | ||
('4','4','ad','et','Repudiandae porro explicabo officiis sed quis voluptate et.','1978-12-13'), | ||
('5','5','deserunt','temporibus','Mollitia reiciendis debitis est voluptatem est neque.','1979-12-06') | ||
GO | ||
|
||
CREATE SCHEMA [lbcat2] AUTHORIZATION [dbo] | ||
GO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters