Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 4, 2023
Merged
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
33 changes: 21 additions & 12 deletions packages/cli/src/api/e2e.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,30 +36,39 @@ type Feature = keyof typeof enabledFeatures;

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 connection = Db.getConnection();
const allTables: Array<{ name: string }> = await connection.query(
"SELECT name FROM sqlite_master WHERE type='table';",
);

// Disable foreign key constraint checks
await connection.query('PRAGMA foreign_keys = OFF;');

for (const { name: table } of allTables) {
for (const table of tablesToTruncate) {
try {
if (tablesNotToTruncate.includes(table)) continue;
await connection.query(
`DELETE FROM ${table}; DELETE FROM sqlite_sequence WHERE name=${table};`,
);
} catch (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 () => {
Expand Down