Some checks are pending
Bidi Control Character Guard / bidi-control-guard (push) Waiting to run
Circular Dependency Check / Check for new circular dependencies (push) Waiting to run
Citus Migration Smoke / Combined migrations on single-node Citus (push) Waiting to run
E2E Fresh Install Tests / fresh-install-e2e (push) Waiting to run
ext-v2 guardrails / Run ext-v2 guard and ESLint (push) Waiting to run
Integration Tests / Check for relevant changes (push) Waiting to run
Integration Tests / ${{ (github.event_name == 'schedule' || github.event.inputs.suite == 'full') && 'Full integration suite' || 'Tier-1 integration subset' }} (push) Blocked by required conditions
Mobile checks / Mobile lint + typecheck (push) Waiting to run
Mobile checks / Mobile unit tests (push) Waiting to run
Mobile checks / Mobile dependency audit (report) (push) Waiting to run
Mobile checks / Mobile reproducibility checks (push) Waiting to run
Secrets guard (env backups) / Ensure no tracked env backup files (push) Waiting to run
Temporal Readiness / fast-readiness (push) Waiting to run
Temporal Readiness / docker-parity (push) Waiting to run
TypeScript Type Check / Nx affected typecheck (push) Waiting to run
Unit Tests / Skipped-test budget (push) Waiting to run
Unit Tests / Nx affected unit tests (push) Waiting to run
Unit Tests / Server unit coverage (informational) (push) Waiting to run
Validate Tenant Management Schema / Check for relevant changes (push) Waiting to run
Validate Tenant Management Schema / Validate Tenant Management Schema (push) Blocked by required conditions
EE Workflows Build Guard / ee-workflows-build-guard (push) Waiting to run
Excluded: .git, node_modules, secrets/, compose.env, assemblyscript tgz Source: /opt/alga-psa on psa.joliet.tech
51 lines
2.3 KiB
JavaScript
51 lines
2.3 KiB
JavaScript
exports.up = async function(knex) {
|
|
// Remove document associations for schedule type
|
|
await knex.raw(`DELETE FROM document_associations WHERE entity_type = 'schedule';`);
|
|
|
|
// Remove row-level security policy for schedules table
|
|
const schedulesTableExists = await knex.schema.hasTable('schedules');
|
|
if (schedulesTableExists) {
|
|
await knex.raw('DROP POLICY IF EXISTS tenant_isolation_policy ON schedules;');
|
|
await knex.raw('ALTER TABLE schedules DISABLE ROW LEVEL SECURITY;');
|
|
}
|
|
|
|
// Drop the schedules table
|
|
await knex.schema.dropTableIfExists('schedules');
|
|
}
|
|
|
|
exports.down = async function(knex) {
|
|
// Recreate the schedules table
|
|
await knex.schema.createTable('schedules', function(table) {
|
|
table.uuid('tenant').notNullable();
|
|
table.uuid('schedule_id').notNullable();
|
|
table.uuid('ticket_id').notNullable();
|
|
table.uuid('user_id').nullable();
|
|
table.uuid('contact_name_id').nullable();
|
|
table.uuid('company_id').nullable();
|
|
table.text('status').notNullable();
|
|
table.timestamp('scheduled_start', { useTz: true }).nullable();
|
|
table.timestamp('scheduled_end', { useTz: true }).nullable();
|
|
table.timestamp('actual_start', { useTz: true }).nullable();
|
|
table.timestamp('actual_end', { useTz: true }).nullable();
|
|
table.integer('duration_minutes').nullable();
|
|
table.text('description').nullable();
|
|
table.timestamp('created_at', { useTz: true }).nullable();
|
|
table.timestamp('updated_at', { useTz: true }).nullable();
|
|
|
|
// Primary key
|
|
table.primary(['tenant', 'schedule_id']);
|
|
|
|
// Foreign keys
|
|
table.foreign(['tenant', 'company_id']).references(['tenant', 'company_id']).inTable('companies');
|
|
table.foreign(['tenant', 'contact_name_id']).references(['tenant', 'contact_name_id']).inTable('contacts');
|
|
table.foreign(['tenant']).references(['tenant']).inTable('tenants');
|
|
table.foreign(['tenant', 'ticket_id']).references(['tenant', 'ticket_id']).inTable('tickets');
|
|
table.foreign(['tenant', 'user_id']).references(['tenant', 'user_id']).inTable('users');
|
|
});
|
|
|
|
// Add row-level security policy
|
|
await knex.raw('ALTER TABLE schedules ENABLE ROW LEVEL SECURITY;');
|
|
await knex.raw(`CREATE POLICY tenant_isolation_policy ON schedules
|
|
USING (tenant::text = current_setting('app.current_tenant'));`);
|
|
}
|