Skip to content

Commit 0f69473

Browse files
authored
Merge pull request #30 from jasonlyle88/dbcl_filename_directory_sep_test
Add test for databasechangelog.filename directory separator
2 parents 3a9284c + ad5221d commit 0f69473

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
-- Make sure the liquibase changelog table exists
2+
prompt "Run liquibase validate"
3+
liquibase validate -database-changelog-table-name &1._changelog -changelog-file sqlcl-liquibase-databasechangelog-filename-directory-seperator/changelog.xml
4+
5+
-- Call to see if functionality works
6+
prompt "Run liquibase update"
7+
liquibase update -database-changelog-table-name &1._changelog -changelog-file sqlcl-liquibase-databasechangelog-filename-directory-seperator/changelog.xml
8+
9+
-- See if any changesets were run
10+
prompt "Check changesets ran"
11+
declare
12+
c_table_name constant varchar2(255 char) := '&1._changelog';
13+
l_count number;
14+
begin
15+
execute immediate 'select count(1) from ' || c_table_name
16+
into l_count;
17+
18+
if l_count = 0 then
19+
raise_application_error(-20001, 'Liquibase update did not run');
20+
end if;
21+
end;
22+
/
23+
24+
-- Check filename directory separator directions
25+
prompt "Check changesets ran"
26+
declare
27+
c_root constant varchar2(255 char) := 'sqlcl-liquibase-databasechangelog-filename-directory-seperator';
28+
c_table_name constant varchar2(255 char) := '&1._changelog';
29+
l_id varchar2(255 char);
30+
l_filename varchar2(255 char);
31+
begin
32+
l_id := 'opensouce_liquibase_change';
33+
execute immediate 'select filename from ' || c_table_name || ' where id = :1'
34+
into l_filename
35+
using in l_id;
36+
37+
if l_filename != c_root || '/a/b/c/child.sql' then
38+
raise_application_error(-20002, 'Open source liquibase change did not match expected filename ("' || l_filename || '"")');
39+
end if;
40+
41+
l_id := 'sqlcl_liquibase_runoraclescript_change';
42+
execute immediate 'select filename from ' || c_table_name || ' where id = :1'
43+
into l_filename
44+
using in l_id;
45+
46+
if l_filename != c_root || '/a/b/c/child.xml' then
47+
raise_application_error(-20003, 'runOracleScript change did not match expected filename ("' || l_filename || '"")');
48+
end if;
49+
50+
l_id := 'sqlcl_liquibase_runapexscript_change';
51+
execute immediate 'select filename from ' || c_table_name || ' where id = :1'
52+
into l_filename
53+
using in l_id;
54+
55+
if l_filename != c_root || '/a/b/c/child.xml' then
56+
raise_application_error(-20004, 'runApexScript change did not match expected filename ("' || l_filename || '"")');
57+
end if;
58+
end;
59+
/
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
--liquibase formatted sql
2+
3+
--changeset jlyle:opensouce_liquibase_change stripComments:false runOnChange:true runAlways:false
4+
select 1 from sys.dual;
5+
--rollback not required
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:ora="http://www.oracle.com/xml/ns/dbchangelog-ext"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd"
7+
>
8+
<include relativeToChangelogFile="true" file="child.sql" />
9+
10+
<changeSet
11+
author="jlyle"
12+
id="sqlcl_liquibase_runoraclescript_change"
13+
runOnChange="true"
14+
runAlways="false"
15+
>
16+
<ora:runOracleScript ownerName="jlyle" sourceType="FILE" objectType="SCRIPT" objectName="demo" relativeToChangelogFile="true" >
17+
<ora:source>
18+
child.sql
19+
</ora:source>
20+
</ora:runOracleScript>
21+
</changeSet>
22+
23+
<changeSet
24+
author="jlyle"
25+
id="sqlcl_liquibase_runapexscript_change"
26+
runOnChange="true"
27+
runAlways="false"
28+
>
29+
<ora:runApexScript ownerName="jlyle" sourceType="FILE" objectType="SCRIPT" objectName="demo" relativeToChangelogFile="true" >
30+
<ora:source>
31+
child.sql
32+
</ora:source>
33+
</ora:runApexScript>
34+
</changeSet>
35+
</databaseChangeLog>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<databaseChangeLog
3+
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xmlns:ora="http://www.oracle.com/xml/ns/dbchangelog-ext"
6+
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-4.17.xsd"
7+
>
8+
<include relativeToChangelogFile="true" file="a/b/c/child.xml" />
9+
</databaseChangeLog>

0 commit comments

Comments
 (0)