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
81 lines
3.3 KiB
JavaScript
81 lines
3.3 KiB
JavaScript
/**
|
|
* @param { import("knex").Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
exports.up = function(knex) {
|
|
return knex.schema
|
|
// Create dedicated tenant telemetry settings table
|
|
.createTable('tenant_telemetry_settings', table => {
|
|
table.uuid('tenant').primary();
|
|
table.boolean('enabled').notNullable().defaultTo(true);
|
|
table.boolean('allow_user_override').notNullable().defaultTo(true);
|
|
table.enum('anonymization_level', ['none', 'partial', 'full']).notNullable().defaultTo('partial');
|
|
table.jsonb('exclude_patterns').defaultTo('[]');
|
|
table.text('compliance_notes');
|
|
table.uuid('updated_by').notNullable();
|
|
table.timestamps(true, true);
|
|
|
|
// Foreign key constraints
|
|
table.foreign('tenant').references('tenant').inTable('tenants').onDelete('CASCADE');
|
|
table.foreign(['tenant', 'updated_by']).references(['tenant', 'user_id']).inTable('users').onDelete('RESTRICT');
|
|
})
|
|
|
|
// Create telemetry consent log for compliance tracking
|
|
.createTable('telemetry_consent_log', table => {
|
|
table.increments('id').primary();
|
|
table.uuid('tenant').notNullable();
|
|
table.uuid('user_id').notNullable();
|
|
table.enum('action', ['opted_in', 'opted_out', 'settings_changed', 'consent_given', 'consent_withdrawn']).notNullable();
|
|
table.jsonb('preferences_before');
|
|
table.jsonb('preferences_after');
|
|
table.string('consent_version').notNullable();
|
|
table.text('user_agent');
|
|
table.string('ip_address', 45); // Support IPv4 and IPv6
|
|
table.text('notes');
|
|
table.timestamps(true, true);
|
|
|
|
// Foreign key constraints
|
|
table.foreign('tenant').references('tenant').inTable('tenants').onDelete('CASCADE');
|
|
table.foreign(['tenant', 'user_id']).references(['tenant', 'user_id']).inTable('users').onDelete('CASCADE');
|
|
|
|
// Indexes for performance
|
|
table.index(['tenant', 'user_id']);
|
|
table.index('created_at');
|
|
table.index('action');
|
|
})
|
|
|
|
// Add RLS policies for both tables
|
|
.raw(`
|
|
-- Enable RLS for tenant telemetry settings
|
|
ALTER TABLE tenant_telemetry_settings ENABLE ROW LEVEL SECURITY;
|
|
|
|
CREATE POLICY tenant_isolation_policy ON tenant_telemetry_settings
|
|
USING (tenant = current_setting('app.current_tenant')::uuid)
|
|
WITH CHECK (tenant = current_setting('app.current_tenant')::uuid);
|
|
|
|
-- Enable RLS for telemetry consent log
|
|
ALTER TABLE telemetry_consent_log ENABLE ROW LEVEL SECURITY;
|
|
|
|
CREATE POLICY tenant_isolation_policy ON telemetry_consent_log
|
|
USING (tenant = current_setting('app.current_tenant')::uuid)
|
|
WITH CHECK (tenant = current_setting('app.current_tenant')::uuid);
|
|
`);
|
|
};
|
|
|
|
/**
|
|
* @param { import("knex").Knex } knex
|
|
* @returns { Promise<void> }
|
|
*/
|
|
exports.down = function(knex) {
|
|
return knex.schema
|
|
.raw(`
|
|
-- Drop RLS policies
|
|
DROP POLICY IF EXISTS tenant_isolation_policy ON telemetry_consent_log;
|
|
ALTER TABLE telemetry_consent_log DISABLE ROW LEVEL SECURITY;
|
|
|
|
DROP POLICY IF EXISTS tenant_isolation_policy ON tenant_telemetry_settings;
|
|
ALTER TABLE tenant_telemetry_settings DISABLE ROW LEVEL SECURITY;
|
|
`)
|
|
.dropTableIfExists('telemetry_consent_log')
|
|
.dropTableIfExists('tenant_telemetry_settings');
|
|
}; |