Skip to content

Commit

Permalink
Added offset for add organisation migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed May 13, 2024
1 parent 566ca69 commit 45cd17f
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 51 deletions.
6 changes: 5 additions & 1 deletion db/create-organisation-add-migration.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const fs = require("fs");

// To make all add organisation migration run after the initial migration
const ADD_ORG_MIGRATION_OFFSET = 10000000000; // More than 317 years!

exports.default = function createOrganisationAddMigration(
organisationName,
schemaId,
authorizedAttestor,
color = null
) {
const timestamp = new Date().getTime();
const timestamp = new Date().getTime() + ADD_ORG_MIGRATION_OFFSET;
const fileName = `${timestamp}-Add${organisationName}.js`;
const className = `Add${organisationName.replace(/ /g, "")}${timestamp}`;

Expand Down
25 changes: 0 additions & 25 deletions db/migrations/1715254645149-AddTrace.js

This file was deleted.

25 changes: 0 additions & 25 deletions db/migrations/1715344741698-AddGiveth Verification Team.js

This file was deleted.

23 changes: 23 additions & 0 deletions db/migrations/1725254645149-AddTrace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = class AddTrace1725254645149 {
name = "AddTrace1725254645149";

async up(db) {
// add organisation with name "Trace" and schema id "0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722"
await db.query(
`INSERT INTO "organisation" ("id", "name", "issuer", "color")
VALUES (
'0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722',
'Trace',
'0xf23ea0b5f14afcbe532a1df273f7b233ebe41c78',
'#ff0000'
)`
);
}

async down(db) {
// remove organisation with name "Trace" and schema id "0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722"
await db.query(
`DELETE FROM "organisation" WHERE "id" = '0x2e22df9a11e06c306ed8f64ca45ceae02efcf8a443371395a78371bc4fb6f722'`
);
}
};
23 changes: 23 additions & 0 deletions db/migrations/1725344741698-AddGiveth Verification Team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module.exports = class AddGivethVerificationTeam1725344741698 {
name = "AddGivethVerificationTeam1725344741698";

async up(db) {
// add organisation with name "Giveth Verification Team" and schema id "0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"
await db.query(
`INSERT INTO "organisation" ("id", "name", "issuer", "color")
VALUES (
'0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404',
'Giveth Verification Team',
'0x826976d7c600d45fb8287ca1d7c76fc8eb732030',
'#7f64cb'
)`
);
}

async down(db) {
// remove organisation with name "Giveth Verification Team" and schema id "0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404"
await db.query(
`DELETE FROM "organisation" WHERE "id" = '0xf63f2a7159ee674aa6fce42196a8bb0605eafcf20c19e91a7eafba8d39fa0404'`
);
}
};

0 comments on commit 45cd17f

Please sign in to comment.