backend-plus 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
create or replace function semver_to_decimal(p_semver text) returns decimal
|
|
2
|
+
stable language sql
|
|
3
|
+
as
|
|
4
|
+
$sql$
|
|
5
|
+
select regexp_replace(p_semver, '^(\d+(\.\d*)?)(\D.*|$)$','\1')::decimal;
|
|
6
|
+
$sql$;
|
|
7
|
+
|
|
8
|
+
select *, semver_to_decimal(semver), 'ERROR semver_to_decimal!!!!!!!!!!!!!'
|
|
9
|
+
from (select '12.3.4' semver, 12.3 result
|
|
10
|
+
union values ('12', 12),('12.3',12.3),('12.3.3-r12',12.3),('12b',12)
|
|
11
|
+
)
|
|
12
|
+
where semver_to_decimal(semver) is distinct from result;
|
package/lib/backend-plus.js
CHANGED
|
@@ -2682,20 +2682,18 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
2682
2682
|
}
|
|
2683
2683
|
var schema=db.quoteIdent(be.config.db.schema);
|
|
2684
2684
|
linesCreate.push("set role to "+owner+";");
|
|
2685
|
-
|
|
2686
|
-
$do$
|
|
2685
|
+
var control = `-- CONTROL
|
|
2686
|
+
do $do$
|
|
2687
2687
|
declare
|
|
2688
2688
|
vExpectedVersion text := '${be.config.db["min-version"]}';
|
|
2689
2689
|
vCurrentVersion text := (select setting from pg_settings where name = 'server_version');
|
|
2690
2690
|
begin
|
|
2691
|
-
if
|
|
2691
|
+
if semver_to_decimal(vCurrentVersion) < semver_to_decimal(vExpectedVersion) then
|
|
2692
2692
|
raise exception 'BACKEND-PLUS DUMP: Old PostrgreSQL Version % expected %', vCurrentVersion, vExpectedVersion;
|
|
2693
2693
|
end if;
|
|
2694
2694
|
end;
|
|
2695
2695
|
$do$;
|
|
2696
|
-
|
|
2697
|
-
linesCreate.push(`do
|
|
2698
|
-
$do$
|
|
2696
|
+
do $do$
|
|
2699
2697
|
declare
|
|
2700
2698
|
vExpected text := 'UTF8';
|
|
2701
2699
|
vCurrent text := coalesce((select setting from pg_settings where name = 'server_encoding'),'unknown');
|
|
@@ -2705,7 +2703,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
2705
2703
|
end if;
|
|
2706
2704
|
end;
|
|
2707
2705
|
$do$;
|
|
2708
|
-
|
|
2706
|
+
`;
|
|
2709
2707
|
linesCreate.push("drop schema if exists "+schema+' cascade;');
|
|
2710
2708
|
if (be.config.install.dump["drop-his"]) {
|
|
2711
2709
|
linesCreate.push("drop schema if exists his cascade;");
|
|
@@ -3127,6 +3125,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
|
|
|
3127
3125
|
(complete||opts.forDump? searchPathline.join('\n'): '')+
|
|
3128
3126
|
'\n-- common'+
|
|
3129
3127
|
common+'\n'+
|
|
3128
|
+
control+'\n'+
|
|
3130
3129
|
(complete? '\n\n--prepare.sql\n'+ texts[0]+'\n\n' :'' )+
|
|
3131
3130
|
(complete? texts[3] + '\n\n' : '' )+
|
|
3132
3131
|
'\n-- functions\n' + functionLines.join('\n')+
|
package/package.json
CHANGED