@vrplatform/kysely 1.3.41 → 1.3.45-4444

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/build/.data.tar +0 -0
  2. package/build/main/camel-case/index.js.map +1 -1
  3. package/build/main/control-plane/index.d.ts +142 -0
  4. package/build/main/control-plane/index.js +3 -0
  5. package/build/main/control-plane/index.js.map +1 -0
  6. package/build/main/error.js.map +1 -1
  7. package/build/main/index.d.ts +5 -3
  8. package/build/main/index.js +8 -10
  9. package/build/main/index.js.map +1 -1
  10. package/build/main/isomorphic.js +2 -2
  11. package/build/main/isomorphic.js.map +1 -1
  12. package/build/main/local/digest.js.map +1 -1
  13. package/build/main/local/generate.js.map +1 -1
  14. package/build/main/local/index.js.map +1 -1
  15. package/build/main/local/prune-pulled-schema.js.map +1 -1
  16. package/build/main/pganalyze-comment-plugin/comment-transformer.js +0 -1
  17. package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  18. package/build/main/pganalyze-comment-plugin/index.js +16 -3
  19. package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
  20. package/build/main/plugins.js.map +1 -1
  21. package/build/main/query/listing/status.d.ts +4 -4
  22. package/build/main/query/listing/status.js +2 -1
  23. package/build/main/query/listing/status.js.map +1 -1
  24. package/build/main/regional.d.ts +34 -0
  25. package/build/main/regional.js +145 -0
  26. package/build/main/regional.js.map +1 -0
  27. package/build/main/test/index.js.map +1 -1
  28. package/build/main/transaction.js.map +1 -1
  29. package/build/main/v1.generated.d.ts +123 -1
  30. package/build/main/v1.generated.js.map +1 -1
  31. package/build/migrations/0000000000001-init.ts +5 -0
  32. package/build/migrations/0000000000009-drop-store-schema.ts +14 -0
  33. package/build/migrations/0000000000010-bank-rules.ts +190 -0
  34. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +65 -0
  35. package/build/migrations/0000000000012-bank-rule-conditions.ts +45 -0
  36. package/build/migrations/0000000000013-bank-rule-name-unique.ts +15 -0
  37. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +41 -0
  38. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +70 -0
  39. package/build/migrations/0000000000016-owner-statement-draft-status.ts +22 -0
  40. package/build/migrations/0000000000017-tenant-migration-markers.ts +18 -0
  41. package/build/migrations/0000000000018-security-deposits-payable-category.ts +63 -0
  42. package/build/migrations/0000000000019-tenant-app-settings.ts +76 -0
  43. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +36 -0
  44. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +77 -0
  45. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +30 -0
  46. package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +14 -0
  47. package/build/migrations/0000000000024-listing-parent.ts +37 -0
  48. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +26 -0
  49. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +89 -0
  50. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +52 -0
  51. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +20 -0
  52. package/build/migrations/0000000000029-tenant-slug.ts +328 -0
  53. package/build/migrations/0000000000030-pms-accounting-windows.ts +50 -0
  54. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +20 -0
  55. package/build/migrations/0000000000032-flow-event-listening.ts +28 -0
  56. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +272 -0
  57. package/build/migrations/0000000000034-historic-general-ledger.ts +24 -0
  58. package/build/migrations/0000000000035-tenant-regional-placement.ts +37 -0
  59. package/build/migrations/0000000000036-control-plane-projection-events.ts +43 -0
  60. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +21 -0
  61. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +31 -0
  62. package/build/migrations/0000000000039-crunchy-region.ts +86 -0
  63. package/build/migrations/0000000000040-hostaway-region.ts +72 -0
  64. package/build/migrations/0000000000041-audit-tenant-fk.ts +66 -0
  65. package/build/migrations/0000000000042-ramp-staging-connect-params.ts +35 -0
  66. package/build/migrations/0000000000043-gl-pms-accounting-window-guard.ts +125 -0
  67. package/build/migrations/0000000000044-tenant-cross-region-fks.ts +45 -0
  68. package/build/migrations/0000000000045-cloudflare-region-env.ts +100 -0
  69. package/build/migrations/0000000000046-control-plane-outbox-alias.ts +46 -0
  70. package/build/migrations/0000000000047-ramp-contact-last-4-digits.ts +16 -0
  71. package/build/migrations/0000000000047-tenant-status-backfill.ts +40 -0
  72. package/build/migrations/0000000000048-tenant-status-constraint.ts +24 -0
  73. package/build/migrations/0000000000049-health-tenant-issues.ts +69 -0
  74. package/build/migrations/0000000000050-partner-webhooks.ts +135 -0
  75. package/build/migrations/0000000000051-health-webhook-runtime-grants.ts +42 -0
  76. package/build/migrations/0000000000052-feature-approval-team-enablement.ts +13 -0
  77. package/build/migrations/0000000000053-health-webhook-enums.ts +296 -0
  78. package/build/module/camel-case/index.js.map +1 -1
  79. package/build/module/control-plane/index.d.ts +142 -0
  80. package/build/module/control-plane/index.js +2 -0
  81. package/build/module/control-plane/index.js.map +1 -0
  82. package/build/module/error.js.map +1 -1
  83. package/build/module/index.d.ts +5 -3
  84. package/build/module/index.js +8 -10
  85. package/build/module/index.js.map +1 -1
  86. package/build/module/isomorphic.js.map +1 -1
  87. package/build/module/local/digest.js.map +1 -1
  88. package/build/module/local/generate.js.map +1 -1
  89. package/build/module/local/index.js.map +1 -1
  90. package/build/module/local/prune-pulled-schema.js.map +1 -1
  91. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  92. package/build/module/pganalyze-comment-plugin/index.js.map +1 -1
  93. package/build/module/plugins.js.map +1 -1
  94. package/build/module/query/listing/status.d.ts +4 -4
  95. package/build/module/query/listing/status.js +2 -1
  96. package/build/module/query/listing/status.js.map +1 -1
  97. package/build/module/regional.d.ts +34 -0
  98. package/build/module/regional.js +103 -0
  99. package/build/module/regional.js.map +1 -0
  100. package/build/module/test/index.js.map +1 -1
  101. package/build/module/transaction.js.map +1 -1
  102. package/build/module/v1.generated.d.ts +123 -1
  103. package/build/module/v1.generated.js.map +1 -1
  104. package/package.json +13 -4
  105. package/build/main/tsconfig.main.tsbuildinfo +0 -1
  106. package/build/module/tsconfig.esm.tsbuildinfo +0 -1
@@ -0,0 +1,45 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table accounting.bank_rule
7
+ add column if not exists match_mode text not null default 'all';
8
+ `.execute(db);
9
+
10
+ await sql`
11
+ create table if not exists accounting.bank_rule_condition (
12
+ id uuid default gen_random_uuid() primary key,
13
+ created_at timestamptz not null default now(),
14
+ updated_at timestamptz not null default now(),
15
+ tenant_id uuid not null references public.tenant(id) on update restrict on delete restrict,
16
+ bank_rule_id uuid not null references accounting.bank_rule(id) on update restrict on delete cascade,
17
+ sort_order integer not null,
18
+ condition_type text not null,
19
+ operator text not null,
20
+ text_value text null,
21
+ cent_value integer null
22
+ );
23
+ `.execute(db);
24
+
25
+ await sql`
26
+ create index if not exists bank_rule_condition_rule_id_sort_order_idx
27
+ on accounting.bank_rule_condition (bank_rule_id, sort_order);
28
+ `.execute(db);
29
+
30
+ await sql`
31
+ create unique index if not exists bank_rule_condition_rule_id_sort_order_unique_idx
32
+ on accounting.bank_rule_condition (bank_rule_id, sort_order);
33
+ `.execute(db);
34
+ }
35
+
36
+ export async function down(db: Kysely<any>): Promise<void> {
37
+ await sql`
38
+ drop table if exists accounting.bank_rule_condition cascade;
39
+ `.execute(db);
40
+
41
+ await sql`
42
+ alter table accounting.bank_rule
43
+ drop column if exists match_mode;
44
+ `.execute(db);
45
+ }
@@ -0,0 +1,15 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ create unique index if not exists bank_rule_tenant_name_unique_idx
7
+ on accounting.bank_rule (tenant_id, lower(name));
8
+ `.execute(db);
9
+ }
10
+
11
+ export async function down(db: Kysely<any>): Promise<void> {
12
+ await sql`
13
+ drop index if exists accounting.bank_rule_tenant_name_unique_idx;
14
+ `.execute(db);
15
+ }
@@ -0,0 +1,41 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table accounting.bank_rule
7
+ drop constraint if exists bank_rule_description_operator_fkey;
8
+ `.execute(db);
9
+
10
+ await sql`
11
+ alter table accounting.bank_rule
12
+ drop column if exists description_operator,
13
+ drop column if exists description_value,
14
+ drop column if exists amount_min_cent,
15
+ drop column if exists amount_max_cent;
16
+ `.execute(db);
17
+ }
18
+
19
+ export async function down(db: Kysely<any>): Promise<void> {
20
+ await sql`
21
+ alter table accounting.bank_rule
22
+ add column if not exists description_operator text null,
23
+ add column if not exists description_value text null,
24
+ add column if not exists amount_min_cent integer null,
25
+ add column if not exists amount_max_cent integer null;
26
+ `.execute(db);
27
+
28
+ await sql`
29
+ alter table accounting.bank_rule
30
+ drop constraint if exists bank_rule_description_operator_fkey;
31
+ `.execute(db);
32
+
33
+ await sql`
34
+ alter table accounting.bank_rule
35
+ add constraint bank_rule_description_operator_fkey
36
+ foreign key (description_operator)
37
+ references accounting.bank_rule_match_operator(name)
38
+ on update restrict
39
+ on delete restrict;
40
+ `.execute(db);
41
+ }
@@ -0,0 +1,70 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table public.booking_channel
7
+ add column if not exists icon_provider text null;
8
+ `.execute(db);
9
+
10
+ await sql`
11
+ update public.booking_channel
12
+ set icon_provider = 'cloudflare'
13
+ where icon is not null
14
+ and icon_provider is null;
15
+ `.execute(db);
16
+
17
+ await sql`
18
+ alter table public.booking_channel
19
+ drop constraint if exists booking_channel_icon_provider_check;
20
+ `.execute(db);
21
+
22
+ await sql`
23
+ alter table public.booking_channel
24
+ add constraint booking_channel_icon_provider_check
25
+ check (
26
+ icon_provider is null
27
+ or icon_provider in ('cloudflare', 'logo_dev')
28
+ );
29
+ `.execute(db);
30
+
31
+ await sql`
32
+ alter table public.booking_channel_icon_candidate
33
+ add column if not exists provider text not null default 'cloudflare',
34
+ add column if not exists external_icon text null;
35
+ `.execute(db);
36
+
37
+ await sql`
38
+ alter table public.booking_channel_icon_candidate
39
+ drop constraint if exists booking_channel_icon_candidate_provider_check;
40
+ `.execute(db);
41
+
42
+ await sql`
43
+ alter table public.booking_channel_icon_candidate
44
+ add constraint booking_channel_icon_candidate_provider_check
45
+ check (provider in ('cloudflare', 'logo_dev'));
46
+ `.execute(db);
47
+ }
48
+
49
+ export async function down(db: Kysely<any>): Promise<void> {
50
+ await sql`
51
+ alter table public.booking_channel
52
+ drop constraint if exists booking_channel_icon_provider_check;
53
+ `.execute(db);
54
+
55
+ await sql`
56
+ alter table public.booking_channel_icon_candidate
57
+ drop constraint if exists booking_channel_icon_candidate_provider_check;
58
+ `.execute(db);
59
+
60
+ await sql`
61
+ alter table public.booking_channel
62
+ drop column if exists icon_provider;
63
+ `.execute(db);
64
+
65
+ await sql`
66
+ alter table public.booking_channel_icon_candidate
67
+ drop column if exists provider,
68
+ drop column if exists external_icon;
69
+ `.execute(db);
70
+ }
@@ -0,0 +1,22 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ insert into public.owner_statement_status (name)
7
+ values ('draft')
8
+ on conflict (name) do nothing;
9
+ `.execute(db);
10
+ }
11
+
12
+ export async function down(db: Kysely<any>): Promise<void> {
13
+ await sql`
14
+ delete from public.owner_statement_status
15
+ where name = 'draft'
16
+ and not exists (
17
+ select 1
18
+ from public.owner_statement
19
+ where status = 'draft'
20
+ );
21
+ `.execute(db);
22
+ }
@@ -0,0 +1,18 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table public.tenant
7
+ add column if not exists migrated_from_tenant_id uuid null,
8
+ add column if not exists historical_statements_imported_at timestamp with time zone null;
9
+ `.execute(db);
10
+ }
11
+
12
+ export async function down(db: Kysely<any>): Promise<void> {
13
+ await sql`
14
+ alter table public.tenant
15
+ drop column if exists historical_statements_imported_at,
16
+ drop column if exists migrated_from_tenant_id;
17
+ `.execute(db);
18
+ }
@@ -0,0 +1,63 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ const SECURITY_DEPOSITS_PAYABLE_ID =
5
+ '99897b55-6796-464b-8515-08664610baa7' as const;
6
+ const OTHER_CURRENT_LIABILITIES_ID =
7
+ '765de1ab-c18f-4b59-9523-7a6ad866d0c7' as const;
8
+
9
+ export async function up(db: Kysely<any>): Promise<void> {
10
+ await sql`
11
+ insert into accounting.account_category (
12
+ id,
13
+ name,
14
+ classification,
15
+ "index"
16
+ )
17
+ values (
18
+ ${SECURITY_DEPOSITS_PAYABLE_ID}::uuid,
19
+ 'Security Deposits Payable',
20
+ 'liability',
21
+ 31
22
+ )
23
+ on conflict (id) do update
24
+ set name = excluded.name,
25
+ classification = excluded.classification,
26
+ "index" = excluded."index";
27
+ `.execute(db);
28
+
29
+ await sql`
30
+ update accounting.account_category
31
+ set "index" = 32
32
+ where id = ${OTHER_CURRENT_LIABILITIES_ID}::uuid;
33
+ `.execute(db);
34
+
35
+ await sql`
36
+ update accounting.account
37
+ set category_id = ${SECURITY_DEPOSITS_PAYABLE_ID}::uuid
38
+ where category_id = ${OTHER_CURRENT_LIABILITIES_ID}::uuid
39
+ and (
40
+ title ilike '%security deposit%'
41
+ or title ilike '%security deposits%'
42
+ );
43
+ `.execute(db);
44
+ }
45
+
46
+ export async function down(db: Kysely<any>): Promise<void> {
47
+ await sql`
48
+ update accounting.account
49
+ set category_id = ${OTHER_CURRENT_LIABILITIES_ID}::uuid
50
+ where category_id = ${SECURITY_DEPOSITS_PAYABLE_ID}::uuid;
51
+ `.execute(db);
52
+
53
+ await sql`
54
+ update accounting.account_category
55
+ set "index" = 31
56
+ where id = ${OTHER_CURRENT_LIABILITIES_ID}::uuid;
57
+ `.execute(db);
58
+
59
+ await sql`
60
+ delete from accounting.account_category
61
+ where id = ${SECURITY_DEPOSITS_PAYABLE_ID}::uuid;
62
+ `.execute(db);
63
+ }
@@ -0,0 +1,76 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table public.tenant
7
+ add column app_settings jsonb;
8
+ `.execute(db);
9
+
10
+ await sql`
11
+ comment on column public.tenant.app_settings is
12
+ 'JSON column for app-owned tenant settings exposed through APIs.';
13
+ `.execute(db);
14
+
15
+ await sql`
16
+ update public.tenant as tenant
17
+ set app_settings = coalesce(tenant.app_settings, '{}'::jsonb)
18
+ || jsonb_build_object(
19
+ 'showReservations',
20
+ exists (
21
+ select 1
22
+ from public.setting as setting
23
+ where setting.tenant_id = tenant.id
24
+ and setting.key = 'tenantSettings'
25
+ and setting.target = 'showReservations'
26
+ ),
27
+ 'showCancelledReservations',
28
+ not exists (
29
+ select 1
30
+ from public.setting as setting
31
+ where setting.tenant_id = tenant.id
32
+ and setting.key = 'tenantSettings'
33
+ and setting.target = 'hideCancelledReservations'
34
+ ),
35
+ 'showReservationTotal',
36
+ not exists (
37
+ select 1
38
+ from public.setting as setting
39
+ where setting.tenant_id = tenant.id
40
+ and setting.key = 'tenantSettings'
41
+ and setting.target = 'hideReservationTotal'
42
+ ),
43
+ 'showOwnerCalendarBlocking',
44
+ not exists (
45
+ select 1
46
+ from public.setting as setting
47
+ where setting.tenant_id = tenant.id
48
+ and setting.key = 'tenantSettings'
49
+ and setting.target = 'hideOwnerCalendarBlocking'
50
+ ),
51
+ 'showTaxStatements',
52
+ not exists (
53
+ select 1
54
+ from public.setting as setting
55
+ where setting.tenant_id = tenant.id
56
+ and setting.key = 'tenantSettings'
57
+ and setting.target = 'hideTaxStatements'
58
+ ),
59
+ 'showTwoFactorAuth',
60
+ exists (
61
+ select 1
62
+ from public.setting as setting
63
+ where setting.tenant_id = tenant.id
64
+ and setting.key = 'tenantSettings'
65
+ and setting.target = 'forceTwoFactorAuth'
66
+ )
67
+ );
68
+ `.execute(db);
69
+ }
70
+
71
+ export async function down(db: Kysely<any>): Promise<void> {
72
+ await sql`
73
+ alter table public.tenant
74
+ drop column app_settings;
75
+ `.execute(db);
76
+ }
@@ -0,0 +1,36 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ const JOURNAL_ENTRY_TYPE = 'opening_trial_balance' as const;
5
+
6
+ export async function up(db: Kysely<any>): Promise<void> {
7
+ await sql`
8
+ alter table accounting.account
9
+ add column operating_opening_trial_balance_cent_total bigint not null default 0,
10
+ add column operating_opening_trial_balance_updated_at timestamptz;
11
+ `.execute(db);
12
+
13
+ await sql`
14
+ insert into accounting.journal_entry_type (name)
15
+ values (${JOURNAL_ENTRY_TYPE})
16
+ on conflict (name) do nothing;
17
+ `.execute(db);
18
+ }
19
+
20
+ export async function down(db: Kysely<any>): Promise<void> {
21
+ await sql`
22
+ delete from accounting.journal_entry
23
+ where type = ${JOURNAL_ENTRY_TYPE};
24
+ `.execute(db);
25
+
26
+ await sql`
27
+ delete from accounting.journal_entry_type
28
+ where name = ${JOURNAL_ENTRY_TYPE};
29
+ `.execute(db);
30
+
31
+ await sql`
32
+ alter table accounting.account
33
+ drop column operating_opening_trial_balance_cent_total,
34
+ drop column operating_opening_trial_balance_updated_at;
35
+ `.execute(db);
36
+ }
@@ -0,0 +1,77 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ create index if not exists audit_action_parent_action_idx
7
+ on audit.action (parent_action_id)
8
+ where parent_action_id is not null;
9
+ `.execute(db);
10
+
11
+ await sql`
12
+ create index if not exists audit_journal_delta_action_idx
13
+ on audit.journal_delta (action_id);
14
+ `.execute(db);
15
+
16
+ await sql`
17
+ create index if not exists audit_journal_delta_effect_idx
18
+ on audit.journal_delta (effect_id)
19
+ where effect_id is not null;
20
+ `.execute(db);
21
+
22
+ await sql`
23
+ create index if not exists audit_journal_delta_mutation_idx
24
+ on audit.journal_delta (mutation_id)
25
+ where mutation_id is not null;
26
+ `.execute(db);
27
+
28
+ await sql`
29
+ create index if not exists audit_mutation_action_idx
30
+ on audit.mutation (action_id);
31
+ `.execute(db);
32
+
33
+ await sql`
34
+ create index if not exists audit_mutation_effect_idx
35
+ on audit.mutation (effect_id)
36
+ where effect_id is not null;
37
+ `.execute(db);
38
+
39
+ await sql`
40
+ create index if not exists audit_effect_action_idx
41
+ on audit.effect (action_id);
42
+ `.execute(db);
43
+
44
+ await sql`
45
+ create index if not exists audit_effect_attempt_action_idx
46
+ on audit.effect_attempt (action_id);
47
+ `.execute(db);
48
+
49
+ await sql`
50
+ create index if not exists audit_effect_attempt_effect_idx
51
+ on audit.effect_attempt (effect_id);
52
+ `.execute(db);
53
+ }
54
+
55
+ export async function down(db: Kysely<any>): Promise<void> {
56
+ await sql`drop index if exists audit.audit_action_parent_action_idx;`.execute(
57
+ db
58
+ );
59
+ await sql`drop index if exists audit.audit_effect_attempt_effect_idx;`.execute(
60
+ db
61
+ );
62
+ await sql`drop index if exists audit.audit_effect_attempt_action_idx;`.execute(
63
+ db
64
+ );
65
+ await sql`drop index if exists audit.audit_effect_action_idx;`.execute(db);
66
+ await sql`drop index if exists audit.audit_mutation_effect_idx;`.execute(db);
67
+ await sql`drop index if exists audit.audit_mutation_action_idx;`.execute(db);
68
+ await sql`drop index if exists audit.audit_journal_delta_mutation_idx;`.execute(
69
+ db
70
+ );
71
+ await sql`drop index if exists audit.audit_journal_delta_effect_idx;`.execute(
72
+ db
73
+ );
74
+ await sql`drop index if exists audit.audit_journal_delta_action_idx;`.execute(
75
+ db
76
+ );
77
+ }
@@ -0,0 +1,30 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table accounting.account
7
+ rename column operating_opening_trial_balance_cent_total
8
+ to opening_trial_balance_combined_cent_total;
9
+ `.execute(db);
10
+
11
+ await sql`
12
+ alter table accounting.account
13
+ rename column operating_opening_trial_balance_updated_at
14
+ to opening_trial_balance_updated_at;
15
+ `.execute(db);
16
+ }
17
+
18
+ export async function down(db: Kysely<any>): Promise<void> {
19
+ await sql`
20
+ alter table accounting.account
21
+ rename column opening_trial_balance_combined_cent_total
22
+ to operating_opening_trial_balance_cent_total;
23
+ `.execute(db);
24
+
25
+ await sql`
26
+ alter table accounting.account
27
+ rename column opening_trial_balance_updated_at
28
+ to operating_opening_trial_balance_updated_at;
29
+ `.execute(db);
30
+ }
@@ -0,0 +1,14 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter type accounting.journal_entry_inactive_reason
7
+ add value if not exists 'currencyMismatch'
8
+ before 'unknownInactiveReason';
9
+ `.execute(db);
10
+ }
11
+
12
+ export async function down(_db: Kysely<any>): Promise<void> {
13
+ // PostgreSQL enum values cannot be removed safely without rebuilding the type.
14
+ }
@@ -0,0 +1,37 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table public.listing
7
+ add column parent_id uuid null references public.listing(id)
8
+ on update restrict on delete restrict;
9
+ `.execute(db);
10
+
11
+ await sql`
12
+ create index listing_tenant_id_parent_id_idx
13
+ on public.listing(tenant_id, parent_id);
14
+ `.execute(db);
15
+
16
+ await sql`
17
+ alter table public.listing
18
+ add constraint listing_parent_not_self_check
19
+ check (parent_id is null or parent_id <> id);
20
+ `.execute(db);
21
+ }
22
+
23
+ export async function down(db: Kysely<any>): Promise<void> {
24
+ await sql`
25
+ alter table public.listing
26
+ drop constraint if exists listing_parent_not_self_check;
27
+ `.execute(db);
28
+
29
+ await sql`
30
+ drop index if exists listing_tenant_id_parent_id_idx;
31
+ `.execute(db);
32
+
33
+ await sql`
34
+ alter table public.listing
35
+ drop column if exists parent_id;
36
+ `.execute(db);
37
+ }
@@ -0,0 +1,26 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table accounting.journal_entry
7
+ add column parent_listing_id uuid null references public.listing(id)
8
+ on update restrict on delete restrict;
9
+ `.execute(db);
10
+
11
+ await sql`
12
+ create index journal_entry_tenant_id_parent_listing_id_idx
13
+ on accounting.journal_entry(tenant_id, parent_listing_id);
14
+ `.execute(db);
15
+ }
16
+
17
+ export async function down(db: Kysely<any>): Promise<void> {
18
+ await sql`
19
+ drop index if exists accounting.journal_entry_tenant_id_parent_listing_id_idx;
20
+ `.execute(db);
21
+
22
+ await sql`
23
+ alter table accounting.journal_entry
24
+ drop column if exists parent_listing_id;
25
+ `.execute(db);
26
+ }
@@ -0,0 +1,89 @@
1
+ import type { Kysely } from 'kysely';
2
+ import { sql } from 'kysely';
3
+
4
+ export async function up(db: Kysely<any>): Promise<void> {
5
+ await sql`
6
+ alter table public.booking_channel
7
+ add column if not exists logo text null,
8
+ add column if not exists logo_provider text null,
9
+ add column if not exists selected_booking_channel_logo_candidate_id uuid null;
10
+ `.execute(db);
11
+
12
+ await sql`
13
+ alter table public.booking_channel
14
+ drop constraint if exists booking_channel_logo_provider_check;
15
+ `.execute(db);
16
+
17
+ await sql`
18
+ alter table public.booking_channel
19
+ add constraint booking_channel_logo_provider_check
20
+ check (
21
+ logo_provider is null
22
+ or logo_provider in ('cloudflare', 'logo_dev')
23
+ );
24
+ `.execute(db);
25
+
26
+ await sql`
27
+ alter table public.booking_channel_icon_candidate
28
+ add column if not exists width integer null,
29
+ add column if not exists height integer null;
30
+ `.execute(db);
31
+
32
+ await sql`
33
+ alter table public.booking_channel_icon_candidate
34
+ drop constraint if exists booking_channel_icon_candidate_dimensions_check;
35
+ `.execute(db);
36
+
37
+ await sql`
38
+ alter table public.booking_channel_icon_candidate
39
+ add constraint booking_channel_icon_candidate_dimensions_check
40
+ check (
41
+ (width is null or width > 0)
42
+ and (height is null or height > 0)
43
+ );
44
+ `.execute(db);
45
+
46
+ await sql`
47
+ alter table public.booking_channel
48
+ drop constraint if exists booking_channel_selected_logo_candidate_same_booking_channel_fk;
49
+ `.execute(db);
50
+
51
+ await sql`
52
+ alter table public.booking_channel
53
+ add constraint booking_channel_selected_logo_candidate_same_booking_channel_fk
54
+ foreign key (id, selected_booking_channel_logo_candidate_id)
55
+ references public.booking_channel_icon_candidate(booking_channel_id, id)
56
+ on update restrict
57
+ on delete restrict;
58
+ `.execute(db);
59
+ }
60
+
61
+ export async function down(db: Kysely<any>): Promise<void> {
62
+ await sql`
63
+ alter table public.booking_channel
64
+ drop constraint if exists booking_channel_selected_logo_candidate_same_booking_channel_fk;
65
+ `.execute(db);
66
+
67
+ await sql`
68
+ alter table public.booking_channel
69
+ drop constraint if exists booking_channel_logo_provider_check;
70
+ `.execute(db);
71
+
72
+ await sql`
73
+ alter table public.booking_channel_icon_candidate
74
+ drop constraint if exists booking_channel_icon_candidate_dimensions_check;
75
+ `.execute(db);
76
+
77
+ await sql`
78
+ alter table public.booking_channel
79
+ drop column if exists selected_booking_channel_logo_candidate_id,
80
+ drop column if exists logo_provider,
81
+ drop column if exists logo;
82
+ `.execute(db);
83
+
84
+ await sql`
85
+ alter table public.booking_channel_icon_candidate
86
+ drop column if exists height,
87
+ drop column if exists width;
88
+ `.execute(db);
89
+ }