Skip to content

Commit

Permalink
Merge branch 'update-sqlite-path-ci' of github.com:Chia-Network/cadt …
Browse files Browse the repository at this point in the history
…into update-sqlite-path-ci
  • Loading branch information
TheLastCicada committed Feb 6, 2024
2 parents 1abc1df + 2a4551b commit 7285d50
Show file tree
Hide file tree
Showing 8 changed files with 271 additions and 142 deletions.
15 changes: 14 additions & 1 deletion src/database/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import _ from 'lodash';
import { Sequelize } from 'sequelize';
import { Sequelize, QueryTypes } from 'sequelize';
import config from '../config/config.js';
import { logger } from '../config/logger.cjs';
import mysql from 'mysql2/promise';
Expand Down Expand Up @@ -158,3 +158,16 @@ export const prepareDb = async () => {

await checkForMigrations(sequelize);
};

// Function to set WAL mode
async function setWALMode() {
try {
await sequelize.authenticate();
await sequelize.query('PRAGMA journal_mode=WAL;', { type: QueryTypes.RAW });
console.log('WAL mode set successfully.');
} catch (error) {
console.error('Unable to set WAL mode:', error);
}
}

setWALMode();
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

export default {
async up(queryInterface, Sequelize) {
await Promise.all(
['audit'].map((table) => {
queryInterface.addColumn(table, 'generation', {
type: Sequelize.INTEGER,
allowNull: true,
});
}),
);
},

async down(queryInterface) {
await Promise.all(
['audit'].map((table) => {
queryInterface.removeColumn(table, 'generation');
}),
);
},
};
5 changes: 5 additions & 0 deletions src/database/migrations/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import AddIsTransferColumn from './20220825124702-add-isTransfer-column';
import AddOrgMetadata from './20220831023546-add-org-metadata';
import OrgSyncStatus from './20231020201652-OrgSyncStatus';
import OrgSyncRemaining from './20231020214357-OrgSyncRemainingCount';
import AddGenerationIndexToAudit from './20231207142225-AddGenerationIndexToAudit';

export const migrations = [
{
Expand Down Expand Up @@ -174,4 +175,8 @@ export const migrations = [
migration: OrgSyncRemaining,
name: '20231020214357-OrgSyncRemainingCount',
},
{
migration: AddGenerationIndexToAudit,
name: '20231207142225-AddGenerationIndexToAudit',
},
];
3 changes: 3 additions & 0 deletions src/models/audit/audit.modeltypes.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,7 @@ module.exports = {
type: Sequelize.DATE,
defaultValue: Sequelize.NOW,
},
generation: {
type: Sequelize.INTEGER,
}
};
Loading

0 comments on commit 7285d50

Please sign in to comment.