Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -229,12 +229,27 @@ function titleCase(str) {
module.exports = {
async up(knex) {
if (await knex.schema.hasTable("recreation_resources")) {
await knex.raw(
"DELETE FROM public_advisory_audits WHERE submitted_by = 'Imported'",
);
await knex.raw(
"DELETE FROM public_advisories WHERE submitted_by = 'Imported'",
);
if (
await knex.schema.hasColumn(
"public_advisory_audits",
"submitted_by_name",
)
) {
await knex.raw(
"DELETE FROM public_advisory_audits WHERE submitted_by_name = 'Imported'",
);

await loadData();
}

if (
await knex.schema.hasColumn("public_advisories", "submitted_by_name")
) {
await knex.raw(
"DELETE FROM public_advisories WHERE submitted_by_name = 'Imported'",
);
}

await loadData();
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,17 @@ const messages = [
module.exports = {
async up(knex) {
if (await knex.schema.hasTable("standard_messages")) {
// If precedence 30 already exists, this migration has already imported all rows.
const precedence30Exists = await knex("standard_messages")
.where({ precedence: 30 })
.first();
if (precedence30Exists) {
strapi.log.info(
"Standard messages already imported (precedence 30 exists). Skipping migration.",
);
return;
}

// create a map of event type names (eventType field) to documentIds
const eventTypes = await knex("event_types").select(
"document_id",
Expand Down Expand Up @@ -140,6 +151,7 @@ module.exports = {
precedence,
description,
eventType: eventTypeDocId,
isActive: true,
},
});
}
Expand Down