ci: Revert full db reset for e2e (no-changelog) (#6182)

This commit is contained in:
OlegIvaniv 2023-05-04 16:19:31 +02:00 committed by GitHub
parent 22b82a43a2
commit 5abdba2304
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -36,20 +36,32 @@ type Feature = keyof typeof enabledFeatures;
Container.get(License).isFeatureEnabled = (feature: Feature) => enabledFeatures[feature] ?? false; Container.get(License).isFeatureEnabled = (feature: Feature) => enabledFeatures[feature] ?? false;
const tablesNotToTruncate = ['sqlite_sequence']; const tablesToTruncate = [
'auth_identity',
'auth_provider_sync_history',
'event_destinations',
'shared_workflow',
'shared_credentials',
'webhook_entity',
'workflows_tags',
'credentials_entity',
'tag_entity',
'workflow_statistics',
'workflow_entity',
'execution_entity',
'settings',
'installed_packages',
'installed_nodes',
'user',
'role',
'variables',
];
const truncateAll = async () => { const truncateAll = async () => {
const connection = Db.getConnection(); const connection = Db.getConnection();
const allTables: Array<{ name: string }> = await connection.query(
"SELECT name FROM sqlite_master WHERE type='table';",
);
// Disable foreign key constraint checks for (const table of tablesToTruncate) {
await connection.query('PRAGMA foreign_keys = OFF;');
for (const { name: table } of allTables) {
try { try {
if (tablesNotToTruncate.includes(table)) continue;
await connection.query( await connection.query(
`DELETE FROM ${table}; DELETE FROM sqlite_sequence WHERE name=${table};`, `DELETE FROM ${table}; DELETE FROM sqlite_sequence WHERE name=${table};`,
); );
@ -57,9 +69,6 @@ const truncateAll = async () => {
console.warn('Dropping Table for E2E Reset error: ', error); console.warn('Dropping Table for E2E Reset error: ', error);
} }
} }
// Re-enable foreign key constraint checks
await connection.query('PRAGMA foreign_keys = ON;');
}; };
const setupUserManagement = async () => { const setupUserManagement = async () => {