Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
basic
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xrm
basic
Commits
2d584da1
Commit
2d584da1
authored
5 years ago
by
Johannes Hörmann
Browse files
Options
Downloads
Patches
Plain Diff
add DB to Liquibase-function
parent
8132ae19
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
process/Sql_lib/process.js
+53
-0
53 additions, 0 deletions
process/Sql_lib/process.js
with
53 additions
and
0 deletions
process/Sql_lib/process.js
+
53
−
0
View file @
2d584da1
import
(
"
system.logging
"
);
import
(
"
system.translate
"
);
import
(
"
system.translate
"
);
import
(
"
system.vars
"
);
import
(
"
system.vars
"
);
import
(
"
system.util
"
);
import
(
"
system.db
"
);
import
(
"
system.db
"
);
import
(
"
system.datetime
"
);
import
(
"
system.datetime
"
);
import
(
"
system.tools
"
);
import
(
"
system.tools
"
);
...
@@ -1369,3 +1371,54 @@ SqlUtils.getResolvingCaseWhen = function(pKeyValueArray, pDbFieldName, pLocale)
...
@@ -1369,3 +1371,54 @@ SqlUtils.getResolvingCaseWhen = function(pKeyValueArray, pDbFieldName, pLocale)
resSql
=
[
resSql
,
preparedValues
];
resSql
=
[
resSql
,
preparedValues
];
return
resSql
;
return
resSql
;
};
};
SqlUtils
.
exportToLiquibase
=
function
(
pAuthor
,
pTableName
,
pColumns
,
pNewUUIDForIndexes
)
{
if
(
!
pNewUUIDForIndexes
)
pNewUUIDForIndexes
=
[]
var
xmlData
=
<
databaseChangeLog
xmlns
=
"
http://www.liquibase.org/xml/ns/dbchangelog
"
xmlns
:
ext
=
"
http://www.liquibase.org/xml/ns/dbchangelog-ext
"
xmlns
:
xsi
=
"
http://www.w3.org/2001/XMLSchema-instance
"
xsi
:
schemaLocation
=
"
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd
"
>
<
/databaseChangeLog>
;
xmlData
.
changeSet
.@
author
=
pAuthor
xmlData
.
changeSet
.@
id
=
util
.
getNewUUID
()
var
dbData
=
db
.
table
(
"
select
"
+
pColumns
.
join
(
"
,
"
)
+
"
from
"
+
pTableName
);
var
types
=
db
.
getColumnTypes
(
pTableName
,
pColumns
);
dbData
.
forEach
(
function
(
pRow
)
{
var
node
=
<
insert
><
/insert>
;
node
.@
tableName
=
pTableName
;
for
(
let
i
=
0
;
i
<
pColumns
.
length
;
i
++
)
{
var
value
=
""
;
for
(
j
=
0
;
j
<
pNewUUIDForIndexes
.
length
;
j
++
)
{
if
(
i
==
pNewUUIDForIndexes
[
j
])
{
value
=
util
.
getNewUUID
();
break
;
}
}
if
(
!
value
)
value
=
pRow
[
i
];
var
col
=
<
column
/>
;
col
.@
name
=
pColumns
[
i
];
if
(
SQLTYPES
.
isNumberType
(
types
[
i
]))
col
.@
valueNumeric
=
value
;
else
col
.@
value
=
value
;
node
.
appendChild
(
col
);
}
this
.
appendChild
(
node
);
},
xmlData
.
changeSet
);
//xmlData.changeSet.push(<insert>6</insert>);
return
xmlData
.
toXMLString
()
};
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment