Skip to content

Commit

Permalink
Merge pull request #733 from liquibase/DAT-16820
Browse files Browse the repository at this point in the history
DAT-16820. refactored cloud DBs init-scripts to follow Liquibase atomic changes best practice
  • Loading branch information
PavloTytarchuk authored Feb 6, 2024
2 parents 5bfe7a7 + 12bb937 commit fd53089
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 17 deletions.
4 changes: 3 additions & 1 deletion src/test/resources/init-changelogs/aws/mariadb.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
--liquibase formatted sql
--changeset liquibase:1 runAlways:true

DROP TABLE IF EXISTS `authors`;
CREATE TABLE `authors` (
`id` int(11) NOT NULL AUTO_INCREMENT,
Expand All @@ -12,12 +11,14 @@ CREATE TABLE `authors` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:2 runAlways:true
INSERT INTO `authors` VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
Expand All @@ -28,6 +29,7 @@ CREATE TABLE `posts` (
`inserted_date` date
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:4 runAlways:true
INSERT INTO `posts` VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
Expand Down
14 changes: 7 additions & 7 deletions src/test/resources/init-changelogs/aws/mssql.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
--liquibase formatted sql
--changeset liquibase:1 runAlways:true

DROP TABLE IF EXISTS [dbo].[authors]

CREATE TABLE [dbo].[authors](
[id] [int] NOT NULL,
[first_name] [varchar](255) NOT NULL,
Expand All @@ -13,15 +11,16 @@ CREATE TABLE [dbo].[authors](
CONSTRAINT [PK_PrimaryKey] PRIMARY KEY ([id])
) ON [PRIMARY]

INSERT INTO [dbo].[authors] ([id],[first_name],[last_name],[email],[birthdate],[added])
VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
--changeset liquibase:2 runAlways:true
INSERT INTO [dbo].[authors] ([id],[first_name],[last_name],[email],[birthdate],[added])
VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00')

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS [dbo].[posts]

CREATE TABLE [dbo].[posts](
[id] [int] NOT NULL,
[author_id] [int] NOT NULL,
Expand All @@ -31,8 +30,9 @@ CREATE TABLE [dbo].[posts](
[inserted_date] [date] NULL
) ON [PRIMARY]

INSERT INTO [dbo].[posts] ([id],[author_id],[title],[description],[content],[inserted_date])
VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
--changeset liquibase:4 runAlways:true
INSERT INTO [dbo].[posts] ([id],[author_id],[title],[description],[content],[inserted_date])
VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
('4','4','itaque','deleniti','Magni nam optio id recusandae.','2010-07-28'),
Expand Down
4 changes: 4 additions & 0 deletions src/test/resources/init-changelogs/aws/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ CREATE TABLE `authors` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:2 runAlways:true
INSERT INTO `authors` VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
Expand All @@ -27,10 +29,12 @@ CREATE TABLE `posts` (
`inserted_date` date
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:4 runAlways:true
INSERT INTO `posts` VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
('4','4','itaque','deleniti','Magni nam optio id recusandae.','2010-07-28'),
('5','5','ad','similique','Rerum tempore quis ut nesciunt qui excepturi est.','2006-10-09');

--changeset liquibase:5 runAlways:true
SET GLOBAL log_bin_trust_function_creators = 1;
5 changes: 3 additions & 2 deletions src/test/resources/init-changelogs/aws/postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ CREATE TABLE authors (
PRIMARY KEY (id)
);

--changeset liquibase:2 runAlways:true
INSERT INTO authors VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');


--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS posts;
CREATE TABLE posts (
id SERIAL,
Expand All @@ -28,7 +29,7 @@ CREATE TABLE posts (
inserted_date date
);


--changeset liquibase:4 runAlways:true
INSERT INTO posts VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/init-changelogs/azure/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ CREATE TABLE `authors` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:2 runAlways:true
INSERT INTO `authors` VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
Expand All @@ -27,6 +29,7 @@ CREATE TABLE `posts` (
`inserted_date` date
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:4 runAlways:true
INSERT INTO `posts` VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
Expand Down
5 changes: 3 additions & 2 deletions src/test/resources/init-changelogs/azure/postgresql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ CREATE TABLE authors (
PRIMARY KEY (id)
);

--changeset liquibase:2 runAlways:true
INSERT INTO authors VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');


--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS posts;
CREATE TABLE posts (
id SERIAL,
Expand All @@ -28,7 +29,7 @@ CREATE TABLE posts (
inserted_date date
);


--changeset liquibase:4 runAlways:true
INSERT INTO posts VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/init-changelogs/azure/sqlserver.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CREATE TABLE [dbo].[authors](
) ON [PRIMARY]
GO

--changeset liquibase:2 runAlways:true
INSERT INTO [dbo].[authors] ([id],[first_name],[last_name],[email],[birthdate],[added])
VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
Expand All @@ -22,6 +23,7 @@ VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 0
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00')
GO

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS [dbo].[posts]
GO

Expand All @@ -35,6 +37,7 @@ CREATE TABLE [dbo].[posts](
) ON [PRIMARY]
GO

--changeset liquibase:4 runAlways:true
INSERT INTO [dbo].[posts] ([id],[author_id],[title],[description],[content],[inserted_date])
VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
Expand Down
12 changes: 8 additions & 4 deletions src/test/resources/init-changelogs/gcp/mssql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ BEGIN
EXEC sp_addrolemember 'db_owner', 'lbuser';
END

--changeset liquibase:2 runAlways:true
DROP TABLE IF EXISTS [lbuser].[authors]

CREATE TABLE [lbuser].[authors](
Expand All @@ -25,13 +26,15 @@ CREATE TABLE [lbuser].[authors](
CONSTRAINT [PK_PrimaryKey] PRIMARY KEY ([id])
) ON [PRIMARY]

INSERT INTO [lbuser].[authors] ([id],[first_name],[last_name],[email],[birthdate],[added])
VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
--changeset liquibase:3 runAlways:true
INSERT INTO [lbuser].[authors] ([id],[first_name],[last_name],[email],[birthdate],[added])
VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00')

--changeset liquibase:4 runAlways:true
DROP TABLE IF EXISTS [lbuser].[posts]

CREATE TABLE [lbuser].[posts](
Expand All @@ -43,8 +46,9 @@ CREATE TABLE [lbuser].[posts](
[inserted_date] [date] NULL
) ON [PRIMARY]

INSERT INTO [lbuser].[posts] ([id],[author_id],[title],[description],[content],[inserted_date])
VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
--changeset liquibase:5 runAlways:true
INSERT INTO [lbuser].[posts] ([id],[author_id],[title],[description],[content],[inserted_date])
VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
('4','4','itaque','deleniti','Magni nam optio id recusandae.','2010-07-28'),
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/init-changelogs/gcp/mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@ CREATE TABLE `authors` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:2 runAlways:true
INSERT INTO `authors` VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS `posts`;
CREATE TABLE `posts` (
`id` int(11) NOT NULL,
Expand All @@ -27,6 +29,7 @@ CREATE TABLE `posts` (
`inserted_date` date
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

--changeset liquibase:4 runAlways:true
INSERT INTO `posts` VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
Expand Down
4 changes: 3 additions & 1 deletion src/test/resources/init-changelogs/snowflake/snowflake.sql
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
-- liquibase formatted sql
-- changeset liquibase:1 runAlways:true

DROP TABLE IF EXISTS AUTHORS;
CREATE TABLE AUTHORS (
id int AUTOINCREMENT(6,1) NOT NULL,
Expand All @@ -12,12 +11,14 @@ CREATE TABLE AUTHORS (
PRIMARY KEY (id)
);

--changeset liquibase:2 runAlways:true
INSERT INTO AUTHORS VALUES ('1','Eileen','Lubowitz','[email protected]','1991-03-04','2004-05-30 02:08:25'),
('2','Tamia','Mayert','[email protected]','2016-03-27','2014-03-21 02:52:00'),
('3','Cyril','Funk','[email protected]','1988-04-21','2011-06-24 18:17:48'),
('4','Nicolas','Buckridge','[email protected]','2017-02-03','2019-04-22 02:04:41'),
('5','Jayden','Walter','[email protected]','2010-02-27','1990-02-04 02:32:00');

--changeset liquibase:3 runAlways:true
DROP TABLE IF EXISTS POSTS;
CREATE TABLE POSTS (
id int NOT NULL,
Expand All @@ -28,6 +29,7 @@ CREATE TABLE POSTS (
inserted_date date
);

--changeset liquibase:4 runAlways:true
INSERT INTO POSTS VALUES ('1','1','temporibus','voluptatum','Fugit non et doloribus repudiandae.','2015-11-18'),
('2','2','ea','aut','Tempora molestias maiores provident molestiae sint possimus quasi.','1975-06-08'),
('3','3','illum','rerum','Delectus recusandae sit officiis dolor.','1975-02-25'),
Expand Down

0 comments on commit fd53089

Please sign in to comment.