@vrplatform/kysely 1.3.40 → 1.3.41-4245

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 +141 -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 +6 -3
  8. package/build/main/index.js +8 -9
  9. package/build/main/index.js.map +1 -1
  10. package/build/main/isomorphic.d.ts +2 -1
  11. package/build/main/isomorphic.js +2 -2
  12. package/build/main/isomorphic.js.map +1 -1
  13. package/build/main/local/digest.js.map +1 -1
  14. package/build/main/local/generate.js +12 -0
  15. package/build/main/local/generate.js.map +1 -1
  16. package/build/main/local/index.d.ts +3 -2
  17. package/build/main/local/index.js +56 -3
  18. package/build/main/local/index.js.map +1 -1
  19. package/build/main/local/prune-pulled-schema.js.map +1 -1
  20. package/build/main/pganalyze-comment-plugin/comment-transformer.js +0 -1
  21. package/build/main/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  22. package/build/main/pganalyze-comment-plugin/index.js +16 -3
  23. package/build/main/pganalyze-comment-plugin/index.js.map +1 -1
  24. package/build/main/plugins.js.map +1 -1
  25. package/build/main/query/listing/status.d.ts +4 -4
  26. package/build/main/query/listing/status.js +19 -2
  27. package/build/main/query/listing/status.js.map +1 -1
  28. package/build/main/regional.d.ts +34 -0
  29. package/build/main/regional.js +145 -0
  30. package/build/main/regional.js.map +1 -0
  31. package/build/main/test/index.js.map +1 -1
  32. package/build/main/transaction.d.ts +7 -0
  33. package/build/main/transaction.js +32 -0
  34. package/build/main/transaction.js.map +1 -0
  35. package/build/main/v1.generated.d.ts +133 -2
  36. package/build/main/v1.generated.js.map +1 -1
  37. package/build/migrations/0000000000001-init.ts +5 -0
  38. package/build/migrations/0000000000009-drop-store-schema.ts +14 -0
  39. package/build/migrations/0000000000010-bank-rules.ts +190 -0
  40. package/build/migrations/0000000000011-bank-rule-line-adjustments.ts +65 -0
  41. package/build/migrations/0000000000012-bank-rule-conditions.ts +45 -0
  42. package/build/migrations/0000000000013-bank-rule-name-unique.ts +15 -0
  43. package/build/migrations/0000000000014-bank-rule-drop-legacy-conditions.ts +41 -0
  44. package/build/migrations/0000000000015-booking-channel-logo-dev-provider.ts +70 -0
  45. package/build/migrations/0000000000016-owner-statement-draft-status.ts +22 -0
  46. package/build/migrations/0000000000017-tenant-migration-markers.ts +18 -0
  47. package/build/migrations/0000000000018-security-deposits-payable-category.ts +63 -0
  48. package/build/migrations/0000000000019-tenant-app-settings.ts +76 -0
  49. package/build/migrations/0000000000020-operating-opening-trial-balance.ts +36 -0
  50. package/build/migrations/0000000000021-audit-foreign-key-indexes.ts +77 -0
  51. package/build/migrations/0000000000022-opening-trial-balance-combined-columns.ts +30 -0
  52. package/build/migrations/0000000000023-journal-entry-currency-mismatch-reason.ts +14 -0
  53. package/build/migrations/0000000000024-listing-parent.ts +37 -0
  54. package/build/migrations/0000000000025-journal-entry-parent-listing.ts +26 -0
  55. package/build/migrations/0000000000026-booking-channel-logo-slots.ts +89 -0
  56. package/build/migrations/0000000000027-list-browse-performance-indexes.ts +52 -0
  57. package/build/migrations/0000000000028-flow-setting-status-jsonb.ts +20 -0
  58. package/build/migrations/0000000000029-tenant-slug.ts +328 -0
  59. package/build/migrations/0000000000030-pms-accounting-windows.ts +50 -0
  60. package/build/migrations/0000000000031-owner-statement-projection-listing-revision.ts +20 -0
  61. package/build/migrations/0000000000032-flow-event-listening.ts +28 -0
  62. package/build/migrations/0000000000033-opening-trial-balance-transaction.ts +272 -0
  63. package/build/migrations/0000000000034-historic-general-ledger.ts +24 -0
  64. package/build/migrations/0000000000035-tenant-regional-placement.ts +37 -0
  65. package/build/migrations/0000000000036-control-plane-projection-events.ts +43 -0
  66. package/build/migrations/0000000000037-tenant-guide-onboarding.ts +21 -0
  67. package/build/migrations/0000000000038-ramp-staging-connect-params.ts +35 -0
  68. package/build/migrations/0000000000038-tracking-event-analytics-sink.ts +31 -0
  69. package/build/migrations/0000000000039-crunchy-region.ts +86 -0
  70. package/build/migrations/0000000000039-gl-pms-accounting-window-guard.ts +125 -0
  71. package/build/migrations/0000000000040-hostaway-region.ts +72 -0
  72. package/build/module/camel-case/index.js.map +1 -1
  73. package/build/module/control-plane/index.d.ts +141 -0
  74. package/build/module/control-plane/index.js +2 -0
  75. package/build/module/control-plane/index.js.map +1 -0
  76. package/build/module/error.js.map +1 -1
  77. package/build/module/index.d.ts +6 -3
  78. package/build/module/index.js +8 -9
  79. package/build/module/index.js.map +1 -1
  80. package/build/module/isomorphic.d.ts +2 -1
  81. package/build/module/isomorphic.js.map +1 -1
  82. package/build/module/local/digest.js.map +1 -1
  83. package/build/module/local/generate.js +12 -0
  84. package/build/module/local/generate.js.map +1 -1
  85. package/build/module/local/index.d.ts +3 -2
  86. package/build/module/local/index.js +23 -3
  87. package/build/module/local/index.js.map +1 -1
  88. package/build/module/local/prune-pulled-schema.js.map +1 -1
  89. package/build/module/pganalyze-comment-plugin/comment-transformer.js.map +1 -1
  90. package/build/module/pganalyze-comment-plugin/index.js.map +1 -1
  91. package/build/module/plugins.js.map +1 -1
  92. package/build/module/query/listing/status.d.ts +4 -4
  93. package/build/module/query/listing/status.js +19 -2
  94. package/build/module/query/listing/status.js.map +1 -1
  95. package/build/module/regional.d.ts +34 -0
  96. package/build/module/regional.js +103 -0
  97. package/build/module/regional.js.map +1 -0
  98. package/build/module/test/index.js.map +1 -1
  99. package/build/module/transaction.d.ts +7 -0
  100. package/build/module/transaction.js +25 -0
  101. package/build/module/transaction.js.map +1 -0
  102. package/build/module/v1.generated.d.ts +133 -2
  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,190 @@
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 table if not exists accounting.bank_rule_mode (
7
+ name text primary key
8
+ );
9
+ `.execute(db);
10
+
11
+ await sql`
12
+ create table if not exists accounting.bank_rule_match_operator (
13
+ name text primary key
14
+ );
15
+ `.execute(db);
16
+
17
+ await sql`
18
+ create table if not exists accounting.bank_rule_line_split_mode (
19
+ name text primary key
20
+ );
21
+ `.execute(db);
22
+
23
+ await sql`
24
+ create table if not exists accounting.bank_rule_application_status (
25
+ name text primary key
26
+ );
27
+ `.execute(db);
28
+
29
+ await sql`
30
+ insert into accounting.bank_rule_mode (name)
31
+ values ('suggest'), ('autoCreateAndMatch')
32
+ on conflict (name) do nothing;
33
+ `.execute(db);
34
+
35
+ await sql`
36
+ insert into accounting.bank_rule_match_operator (name)
37
+ values ('contains'), ('equals'), ('startsWith')
38
+ on conflict (name) do nothing;
39
+ `.execute(db);
40
+
41
+ await sql`
42
+ insert into accounting.bank_rule_line_split_mode (name)
43
+ values ('fixed'), ('percentage'), ('remainder')
44
+ on conflict (name) do nothing;
45
+ `.execute(db);
46
+
47
+ await sql`
48
+ insert into accounting.bank_rule_application_status (name)
49
+ values ('applied'), ('skipped'), ('failed')
50
+ on conflict (name) do nothing;
51
+ `.execute(db);
52
+
53
+ await sql`
54
+ create table if not exists accounting.bank_rule (
55
+ id uuid default gen_random_uuid() primary key,
56
+ created_at timestamptz not null default now(),
57
+ updated_at timestamptz not null default now(),
58
+ tenant_id uuid not null references public.tenant(id) on update restrict on delete restrict,
59
+ name text not null,
60
+ status text not null references core.active_status(name) on update restrict on delete restrict,
61
+ priority integer not null default 0,
62
+ transaction_type text not null references accounting.transaction_type(name) on update restrict on delete restrict,
63
+ mode text not null default 'suggest' references accounting.bank_rule_mode(name) on update restrict on delete restrict,
64
+ description_operator text null references accounting.bank_rule_match_operator(name) on update restrict on delete restrict,
65
+ description_value text null,
66
+ amount_min_cent integer null,
67
+ amount_max_cent integer null,
68
+ description_override text null,
69
+ use_prior_month_end boolean not null default false,
70
+ vendor_contact_id uuid null references accounting.contact(id) on update restrict on delete restrict,
71
+ version integer not null default 1
72
+ );
73
+ `.execute(db);
74
+
75
+ await sql`
76
+ create table if not exists accounting.bank_rule_account (
77
+ id uuid default gen_random_uuid() primary key,
78
+ created_at timestamptz not null default now(),
79
+ updated_at timestamptz not null default now(),
80
+ tenant_id uuid not null references public.tenant(id) on update restrict on delete restrict,
81
+ bank_rule_id uuid not null references accounting.bank_rule(id) on update restrict on delete cascade,
82
+ account_id uuid not null references accounting.account(id) on update restrict on delete restrict
83
+ );
84
+ `.execute(db);
85
+
86
+ await sql`
87
+ create table if not exists accounting.bank_rule_line (
88
+ id uuid default gen_random_uuid() primary key,
89
+ created_at timestamptz not null default now(),
90
+ updated_at timestamptz not null default now(),
91
+ tenant_id uuid not null references public.tenant(id) on update restrict on delete restrict,
92
+ bank_rule_id uuid not null references accounting.bank_rule(id) on update restrict on delete cascade,
93
+ sort_order integer not null,
94
+ split_mode text not null references accounting.bank_rule_line_split_mode(name) on update restrict on delete restrict,
95
+ fixed_cent_amount integer null,
96
+ percentage_bps integer null,
97
+ account_id uuid not null references accounting.account(id) on update restrict on delete restrict,
98
+ listing_id uuid null references public.listing(id) on update restrict on delete restrict,
99
+ party text null references accounting.party(name) on update restrict on delete restrict,
100
+ tax_rate_id uuid null references accounting.rate(id) on update restrict on delete restrict,
101
+ tax_behavior text null references accounting.tax_behavior(name) on update restrict on delete restrict,
102
+ description_override text null
103
+ );
104
+ `.execute(db);
105
+
106
+ await sql`
107
+ create table if not exists accounting.bank_rule_application (
108
+ id uuid default gen_random_uuid() primary key,
109
+ created_at timestamptz not null default now(),
110
+ updated_at timestamptz not null default now(),
111
+ tenant_id uuid not null references public.tenant(id) on update restrict on delete restrict,
112
+ bank_rule_id uuid not null references accounting.bank_rule(id) on update restrict on delete cascade,
113
+ bank_record_id uuid not null references accounting.bank_record(id) on update restrict on delete restrict,
114
+ rule_version integer not null,
115
+ status text not null references accounting.bank_rule_application_status(name) on update restrict on delete restrict,
116
+ created_transaction_id uuid null references accounting.transaction(id) on update restrict on delete restrict,
117
+ error_message text null
118
+ );
119
+ `.execute(db);
120
+
121
+ await sql`
122
+ create index if not exists bank_rule_tenant_id_idx
123
+ on accounting.bank_rule (tenant_id);
124
+ `.execute(db);
125
+
126
+ await sql`
127
+ create index if not exists bank_rule_tenant_status_priority_idx
128
+ on accounting.bank_rule (tenant_id, status, priority desc, created_at desc);
129
+ `.execute(db);
130
+
131
+ await sql`
132
+ create index if not exists bank_rule_account_rule_id_idx
133
+ on accounting.bank_rule_account (bank_rule_id);
134
+ `.execute(db);
135
+
136
+ await sql`
137
+ create index if not exists bank_rule_account_account_id_idx
138
+ on accounting.bank_rule_account (account_id);
139
+ `.execute(db);
140
+
141
+ await sql`
142
+ create unique index if not exists bank_rule_account_unique_idx
143
+ on accounting.bank_rule_account (bank_rule_id, account_id);
144
+ `.execute(db);
145
+
146
+ await sql`
147
+ create index if not exists bank_rule_line_rule_id_sort_order_idx
148
+ on accounting.bank_rule_line (bank_rule_id, sort_order);
149
+ `.execute(db);
150
+
151
+ await sql`
152
+ create unique index if not exists bank_rule_line_rule_id_sort_order_unique_idx
153
+ on accounting.bank_rule_line (bank_rule_id, sort_order);
154
+ `.execute(db);
155
+
156
+ await sql`
157
+ create index if not exists bank_rule_application_bank_record_id_idx
158
+ on accounting.bank_rule_application (bank_record_id);
159
+ `.execute(db);
160
+
161
+ await sql`
162
+ create unique index if not exists bank_rule_application_unique_idx
163
+ on accounting.bank_rule_application (bank_rule_id, bank_record_id, rule_version);
164
+ `.execute(db);
165
+ }
166
+
167
+ export async function down(db: Kysely<any>): Promise<void> {
168
+ await sql`drop table if exists accounting.bank_rule_application cascade;`.execute(
169
+ db
170
+ );
171
+ await sql`drop table if exists accounting.bank_rule_line cascade;`.execute(
172
+ db
173
+ );
174
+ await sql`drop table if exists accounting.bank_rule_account cascade;`.execute(
175
+ db
176
+ );
177
+ await sql`drop table if exists accounting.bank_rule cascade;`.execute(db);
178
+ await sql`drop table if exists accounting.bank_rule_application_status cascade;`.execute(
179
+ db
180
+ );
181
+ await sql`drop table if exists accounting.bank_rule_line_split_mode cascade;`.execute(
182
+ db
183
+ );
184
+ await sql`drop table if exists accounting.bank_rule_match_operator cascade;`.execute(
185
+ db
186
+ );
187
+ await sql`drop table if exists accounting.bank_rule_mode cascade;`.execute(
188
+ db
189
+ );
190
+ }
@@ -0,0 +1,65 @@
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_line
7
+ alter column account_id drop not null;
8
+ `.execute(db);
9
+
10
+ await sql`
11
+ alter table accounting.bank_rule_line
12
+ add column if not exists account_assignment_type text null
13
+ references accounting.account_assignment_type(name)
14
+ on update restrict
15
+ on delete restrict;
16
+ `.execute(db);
17
+
18
+ await sql`
19
+ alter table accounting.bank_rule_line
20
+ add column if not exists markup_cent_total integer null;
21
+ `.execute(db);
22
+
23
+ await sql`
24
+ alter table accounting.bank_rule_line
25
+ add column if not exists markup_tax_rate_id uuid null
26
+ references accounting.rate(id)
27
+ on update restrict
28
+ on delete restrict;
29
+ `.execute(db);
30
+
31
+ await sql`
32
+ alter table accounting.bank_rule_line
33
+ add column if not exists markup_tax_behavior text null
34
+ references accounting.tax_behavior(name)
35
+ on update restrict
36
+ on delete restrict;
37
+ `.execute(db);
38
+ }
39
+
40
+ export async function down(db: Kysely<any>): Promise<void> {
41
+ await sql`
42
+ alter table accounting.bank_rule_line
43
+ drop column if exists markup_tax_behavior;
44
+ `.execute(db);
45
+
46
+ await sql`
47
+ alter table accounting.bank_rule_line
48
+ drop column if exists markup_tax_rate_id;
49
+ `.execute(db);
50
+
51
+ await sql`
52
+ alter table accounting.bank_rule_line
53
+ drop column if exists markup_cent_total;
54
+ `.execute(db);
55
+
56
+ await sql`
57
+ alter table accounting.bank_rule_line
58
+ drop column if exists account_assignment_type;
59
+ `.execute(db);
60
+
61
+ await sql`
62
+ alter table accounting.bank_rule_line
63
+ alter column account_id set not null;
64
+ `.execute(db);
65
+ }
@@ -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
+ }