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
42 lines
1.6 KiB
JavaScript
42 lines
1.6 KiB
JavaScript
exports.up = async function(knex) {
|
|
// Create tenant_settings table for tenant-wide configuration
|
|
await knex.schema.createTable('tenant_settings', (table) => {
|
|
table.uuid('tenant').primary().notNullable();
|
|
table.boolean('onboarding_completed').defaultTo(false);
|
|
table.timestamp('onboarding_completed_at', { useTz: true });
|
|
table.boolean('onboarding_skipped').defaultTo(false);
|
|
table.jsonb('onboarding_data').comment('Stores wizard data for reference/audit');
|
|
table.jsonb('settings').comment('For other tenant-wide settings');
|
|
table.timestamp('created_at', { useTz: true }).defaultTo(knex.fn.now());
|
|
table.timestamp('updated_at', { useTz: true }).defaultTo(knex.fn.now());
|
|
|
|
// Foreign key to tenants table
|
|
table.foreign('tenant').references('tenant').inTable('tenants').onDelete('CASCADE');
|
|
|
|
// Index for faster lookups
|
|
table.index('tenant');
|
|
});
|
|
|
|
// Create a trigger to update the updated_at timestamp
|
|
await knex.raw(`
|
|
CREATE TRIGGER update_tenant_settings_updated_at
|
|
BEFORE UPDATE ON tenant_settings
|
|
FOR EACH ROW
|
|
EXECUTE FUNCTION update_updated_at_column();
|
|
`);
|
|
|
|
// Insert default tenant_settings for existing tenants
|
|
await knex.raw(`
|
|
INSERT INTO tenant_settings (tenant)
|
|
SELECT tenant FROM tenants
|
|
ON CONFLICT (tenant) DO NOTHING;
|
|
`);
|
|
};
|
|
|
|
exports.down = async function(knex) {
|
|
// Drop the trigger first
|
|
await knex.raw('DROP TRIGGER IF EXISTS update_tenant_settings_updated_at ON tenant_settings');
|
|
|
|
// Drop the table
|
|
await knex.schema.dropTableIfExists('tenant_settings');
|
|
}; |