poad 2.54.0 → 2.54.1
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.
- package/package.json +1 -1
- package/project/ref/load.js +1 -0
- package/project/ref/push.js +4 -1
- package/utils/seed/apply.js +16 -4
- package/utils/seed/run.js +2 -1
package/package.json
CHANGED
package/project/ref/load.js
CHANGED
|
@@ -44,6 +44,7 @@ module.exports = (args, raw) =>
|
|
|
44
44
|
const d = await api.call('POST', `v1/projects/${api.enc(id)}/seeds/download`, { body: { target }, what: `reference ${target}` });
|
|
45
45
|
const r = await S.loadLocal(config.project_uuid, d);
|
|
46
46
|
out.log(`${chalk.greenBright('✔')} ${target} loaded locally: ${r.written} rows written, ${r.deleted} removed (${((Date.now() - t0) / 1000).toFixed(1)} s)`);
|
|
47
|
+
for (const w of r.warnings || []) out.log(chalk.yellowBright(` ⚠ ${w}`));
|
|
47
48
|
results.push({ target, ...r });
|
|
48
49
|
}
|
|
49
50
|
out.result({ project: id, local: true, tables: results });
|
package/project/ref/push.js
CHANGED
|
@@ -97,7 +97,10 @@ async function startAndWait(id, branch, targets, opts, out) {
|
|
|
97
97
|
for (const s of st.steps) {
|
|
98
98
|
if (done.has(s.target) || !['done', 'failed'].includes(s.status)) continue;
|
|
99
99
|
done.add(s.target);
|
|
100
|
-
if (s.status === 'done')
|
|
100
|
+
if (s.status === 'done') {
|
|
101
|
+
out.log(`${chalk.greenBright('✔')} ${s.target} loaded into ${branch}: ${s.written} rows written, ${s.deleted} removed (${(s.duration_ms / 1000).toFixed(1)} s)`);
|
|
102
|
+
for (const w of s.warnings || []) out.log(chalk.yellowBright(` ⚠ ${w}`));
|
|
103
|
+
}
|
|
101
104
|
else out.log(`${chalk.redBright('✖')} ${s.target}: ${s.error}`);
|
|
102
105
|
}
|
|
103
106
|
},
|
package/utils/seed/apply.js
CHANGED
|
@@ -51,11 +51,23 @@ function head(target, columns) {
|
|
|
51
51
|
].join('\n');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
/**
|
|
55
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Séquences (serial, identity) des colonnes ENTIÈRES : elles repartent après le plus grand identifiant.
|
|
56
|
+
* Une séquence attachée à une colonne d'un autre type (héritage d'un ancien schéma) est laissée telle
|
|
57
|
+
* quelle, avec un avertissement qui la nomme ; un échec de recalage n'annule pas le chargement.
|
|
58
|
+
*/
|
|
59
|
+
const SEQUENCES = ` for s in select a.attname::text as col, pg_get_serial_sequence(t::text, a.attname) as seq, a.atttypid in ('int2'::regtype, 'int4'::regtype, 'int8'::regtype) as whole
|
|
56
60
|
from pg_attribute a where a.attrelid = t and a.attnum > 0 and not a.attisdropped loop
|
|
57
|
-
if s.seq is
|
|
58
|
-
|
|
61
|
+
if s.seq is null then
|
|
62
|
+
continue;
|
|
63
|
+
elsif not s.whole then
|
|
64
|
+
raise warning 'poad-seed séquence % non recalée : colonne %.% non entière', s.seq, t, s.col;
|
|
65
|
+
else
|
|
66
|
+
begin
|
|
67
|
+
execute format('select setval(%L, coalesce((select max(%I) from %s), 0) + 1, false)', s.seq, s.col, t);
|
|
68
|
+
exception when others then
|
|
69
|
+
raise warning 'poad-seed séquence % non recalée : %', s.seq, sqlerrm;
|
|
70
|
+
end;
|
|
59
71
|
end if;
|
|
60
72
|
end loop;`;
|
|
61
73
|
|
package/utils/seed/run.js
CHANGED
|
@@ -197,7 +197,8 @@ async function loadLocal(container, d, { database } = {}) {
|
|
|
197
197
|
const detail = lines.find((l) => /^DETAIL:/.test(l));
|
|
198
198
|
throw new api.CloudError(`${d.target}: ${e}${detail ? ` — ${detail.replace(/^DETAIL:\s+/, '')}` : ''}`, { code: 'seed_load_failed' });
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
const warnings = out.split('\n').filter((l) => /WARNING:.*poad-seed/.test(l)).map((l) => l.replace(/^.*WARNING:\s+([0-9A-Z]{5}:\s+)?poad-seed\s+/, ''));
|
|
201
|
+
return { ...(A.parseNotice(out) || { written: null, deleted: null }), warnings };
|
|
201
202
|
}
|
|
202
203
|
|
|
203
204
|
/** Dépendances entre tables de l'engine local (ordre de chargement) */
|