Skip to content

Commit 1337b36

Browse files
authored
chore!: remove soft-deletion (#1139)
1 parent 38f8178 commit 1337b36

File tree

11 files changed

+233
-150
lines changed

11 files changed

+233
-150
lines changed

api/docs.go

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,11 +3275,6 @@ const docTemplate = `{
32753275
"type": "string",
32763276
"example": "2022-04-02T19:28:44.491514Z"
32773277
},
3278-
"deletedAt": {
3279-
"description": "Time the resource was marked as deleted",
3280-
"type": "string",
3281-
"example": "2022-04-22T21:01:05.058161Z"
3282-
},
32833278
"external": {
32843279
"description": "Does the account belong to the budget owner or not?",
32853280
"type": "boolean",
@@ -3552,11 +3547,6 @@ const docTemplate = `{
35523547
"type": "string",
35533548
"example": "€"
35543549
},
3555-
"deletedAt": {
3556-
"description": "Time the resource was marked as deleted",
3557-
"type": "string",
3558-
"example": "2022-04-22T21:01:05.058161Z"
3559-
},
35603550
"id": {
35613551
"description": "UUID for the resource",
35623552
"type": "string",
@@ -3734,11 +3724,6 @@ const docTemplate = `{
37343724
"type": "string",
37353725
"example": "2022-04-02T19:28:44.491514Z"
37363726
},
3737-
"deletedAt": {
3738-
"description": "Time the resource was marked as deleted",
3739-
"type": "string",
3740-
"example": "2022-04-22T21:01:05.058161Z"
3741-
},
37423727
"envelopes": {
37433728
"description": "These fields are computed",
37443729
"type": "array",
@@ -3843,11 +3828,6 @@ const docTemplate = `{
38433828
"type": "string",
38443829
"example": "2022-04-02T19:28:44.491514Z"
38453830
},
3846-
"deletedAt": {
3847-
"description": "Time the resource was marked as deleted",
3848-
"type": "string",
3849-
"example": "2022-04-22T21:01:05.058161Z"
3850-
},
38513831
"envelopes": {
38523832
"description": "Slice of all envelopes",
38533833
"type": "array",
@@ -3962,11 +3942,6 @@ const docTemplate = `{
39623942
"type": "string",
39633943
"example": "2022-04-02T19:28:44.491514Z"
39643944
},
3965-
"deletedAt": {
3966-
"description": "Time the resource was marked as deleted",
3967-
"type": "string",
3968-
"example": "2022-04-22T21:01:05.058161Z"
3969-
},
39703945
"id": {
39713946
"description": "UUID for the resource",
39723947
"type": "string",
@@ -4114,11 +4089,6 @@ const docTemplate = `{
41144089
"type": "string",
41154090
"example": "2022-04-02T19:28:44.491514Z"
41164091
},
4117-
"deletedAt": {
4118-
"description": "Time the resource was marked as deleted",
4119-
"type": "string",
4120-
"example": "2022-04-22T21:01:05.058161Z"
4121-
},
41224092
"id": {
41234093
"description": "UUID for the resource",
41244094
"type": "string",
@@ -4222,11 +4192,6 @@ const docTemplate = `{
42224192
"type": "string",
42234193
"example": "2022-04-02T19:28:44.491514Z"
42244194
},
4225-
"deletedAt": {
4226-
"description": "Time the resource was marked as deleted",
4227-
"type": "string",
4228-
"example": "2022-04-22T21:01:05.058161Z"
4229-
},
42304195
"envelopeId": {
42314196
"description": "The ID of the envelope this goal is for",
42324197
"type": "string",
@@ -4485,11 +4450,6 @@ const docTemplate = `{
44854450
"type": "string",
44864451
"example": "2022-04-02T19:28:44.491514Z"
44874452
},
4488-
"deletedAt": {
4489-
"description": "Time the resource was marked as deleted",
4490-
"type": "string",
4491-
"example": "2022-04-22T21:01:05.058161Z"
4492-
},
44934453
"id": {
44944454
"description": "UUID for the resource",
44954455
"type": "string",
@@ -4864,11 +4824,6 @@ const docTemplate = `{
48644824
"type": "string",
48654825
"example": "1815-12-10T18:43:00.271152Z"
48664826
},
4867-
"deletedAt": {
4868-
"description": "Time the resource was marked as deleted",
4869-
"type": "string",
4870-
"example": "2022-04-22T21:01:05.058161Z"
4871-
},
48724827
"destinationAccountId": {
48734828
"description": "ID of the destination account",
48744829
"type": "string",

api/swagger.json

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,11 +3264,6 @@
32643264
"type": "string",
32653265
"example": "2022-04-02T19:28:44.491514Z"
32663266
},
3267-
"deletedAt": {
3268-
"description": "Time the resource was marked as deleted",
3269-
"type": "string",
3270-
"example": "2022-04-22T21:01:05.058161Z"
3271-
},
32723267
"external": {
32733268
"description": "Does the account belong to the budget owner or not?",
32743269
"type": "boolean",
@@ -3541,11 +3536,6 @@
35413536
"type": "string",
35423537
"example": ""
35433538
},
3544-
"deletedAt": {
3545-
"description": "Time the resource was marked as deleted",
3546-
"type": "string",
3547-
"example": "2022-04-22T21:01:05.058161Z"
3548-
},
35493539
"id": {
35503540
"description": "UUID for the resource",
35513541
"type": "string",
@@ -3723,11 +3713,6 @@
37233713
"type": "string",
37243714
"example": "2022-04-02T19:28:44.491514Z"
37253715
},
3726-
"deletedAt": {
3727-
"description": "Time the resource was marked as deleted",
3728-
"type": "string",
3729-
"example": "2022-04-22T21:01:05.058161Z"
3730-
},
37313716
"envelopes": {
37323717
"description": "These fields are computed",
37333718
"type": "array",
@@ -3832,11 +3817,6 @@
38323817
"type": "string",
38333818
"example": "2022-04-02T19:28:44.491514Z"
38343819
},
3835-
"deletedAt": {
3836-
"description": "Time the resource was marked as deleted",
3837-
"type": "string",
3838-
"example": "2022-04-22T21:01:05.058161Z"
3839-
},
38403820
"envelopes": {
38413821
"description": "Slice of all envelopes",
38423822
"type": "array",
@@ -3951,11 +3931,6 @@
39513931
"type": "string",
39523932
"example": "2022-04-02T19:28:44.491514Z"
39533933
},
3954-
"deletedAt": {
3955-
"description": "Time the resource was marked as deleted",
3956-
"type": "string",
3957-
"example": "2022-04-22T21:01:05.058161Z"
3958-
},
39593934
"id": {
39603935
"description": "UUID for the resource",
39613936
"type": "string",
@@ -4103,11 +4078,6 @@
41034078
"type": "string",
41044079
"example": "2022-04-02T19:28:44.491514Z"
41054080
},
4106-
"deletedAt": {
4107-
"description": "Time the resource was marked as deleted",
4108-
"type": "string",
4109-
"example": "2022-04-22T21:01:05.058161Z"
4110-
},
41114081
"id": {
41124082
"description": "UUID for the resource",
41134083
"type": "string",
@@ -4211,11 +4181,6 @@
42114181
"type": "string",
42124182
"example": "2022-04-02T19:28:44.491514Z"
42134183
},
4214-
"deletedAt": {
4215-
"description": "Time the resource was marked as deleted",
4216-
"type": "string",
4217-
"example": "2022-04-22T21:01:05.058161Z"
4218-
},
42194184
"envelopeId": {
42204185
"description": "The ID of the envelope this goal is for",
42214186
"type": "string",
@@ -4474,11 +4439,6 @@
44744439
"type": "string",
44754440
"example": "2022-04-02T19:28:44.491514Z"
44764441
},
4477-
"deletedAt": {
4478-
"description": "Time the resource was marked as deleted",
4479-
"type": "string",
4480-
"example": "2022-04-22T21:01:05.058161Z"
4481-
},
44824442
"id": {
44834443
"description": "UUID for the resource",
44844444
"type": "string",
@@ -4853,11 +4813,6 @@
48534813
"type": "string",
48544814
"example": "1815-12-10T18:43:00.271152Z"
48554815
},
4856-
"deletedAt": {
4857-
"description": "Time the resource was marked as deleted",
4858-
"type": "string",
4859-
"example": "2022-04-22T21:01:05.058161Z"
4860-
},
48614816
"destinationAccountId": {
48624817
"description": "ID of the destination account",
48634818
"type": "string",

api/swagger.yaml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ definitions:
4242
description: Time the resource was created
4343
example: "2022-04-02T19:28:44.491514Z"
4444
type: string
45-
deletedAt:
46-
description: Time the resource was marked as deleted
47-
example: "2022-04-22T21:01:05.058161Z"
48-
type: string
4945
external:
5046
default: false
5147
description: Does the account belong to the budget owner or not?
@@ -254,10 +250,6 @@ definitions:
254250
description: The currency for the budget
255251
example:
256252
type: string
257-
deletedAt:
258-
description: Time the resource was marked as deleted
259-
example: "2022-04-22T21:01:05.058161Z"
260-
type: string
261253
id:
262254
description: UUID for the resource
263255
example: 65392deb-5e92-4268-b114-297faad6cdce
@@ -385,10 +377,6 @@ definitions:
385377
description: Time the resource was created
386378
example: "2022-04-02T19:28:44.491514Z"
387379
type: string
388-
deletedAt:
389-
description: Time the resource was marked as deleted
390-
example: "2022-04-22T21:01:05.058161Z"
391-
type: string
392380
envelopes:
393381
description: These fields are computed
394382
items:
@@ -468,10 +456,6 @@ definitions:
468456
description: Time the resource was created
469457
example: "2022-04-02T19:28:44.491514Z"
470458
type: string
471-
deletedAt:
472-
description: Time the resource was marked as deleted
473-
example: "2022-04-22T21:01:05.058161Z"
474-
type: string
475459
envelopes:
476460
description: Slice of all envelopes
477461
items:
@@ -553,10 +537,6 @@ definitions:
553537
description: Time the resource was created
554538
example: "2022-04-02T19:28:44.491514Z"
555539
type: string
556-
deletedAt:
557-
description: Time the resource was marked as deleted
558-
example: "2022-04-22T21:01:05.058161Z"
559-
type: string
560540
id:
561541
description: UUID for the resource
562542
example: 65392deb-5e92-4268-b114-297faad6cdce
@@ -664,10 +644,6 @@ definitions:
664644
description: Time the resource was created
665645
example: "2022-04-02T19:28:44.491514Z"
666646
type: string
667-
deletedAt:
668-
description: Time the resource was marked as deleted
669-
example: "2022-04-22T21:01:05.058161Z"
670-
type: string
671647
id:
672648
description: UUID for the resource
673649
example: 65392deb-5e92-4268-b114-297faad6cdce
@@ -742,10 +718,6 @@ definitions:
742718
description: Time the resource was created
743719
example: "2022-04-02T19:28:44.491514Z"
744720
type: string
745-
deletedAt:
746-
description: Time the resource was marked as deleted
747-
example: "2022-04-22T21:01:05.058161Z"
748-
type: string
749721
envelopeId:
750722
description: The ID of the envelope this goal is for
751723
example: f81566d9-af4d-4f13-9830-c62c4b5e4c7e
@@ -934,10 +906,6 @@ definitions:
934906
description: Time the resource was created
935907
example: "2022-04-02T19:28:44.491514Z"
936908
type: string
937-
deletedAt:
938-
description: Time the resource was marked as deleted
939-
example: "2022-04-22T21:01:05.058161Z"
940-
type: string
941909
id:
942910
description: UUID for the resource
943911
example: 65392deb-5e92-4268-b114-297faad6cdce
@@ -1217,10 +1185,6 @@ definitions:
12171185
description: Date of the transaction. Time is currently only used for sorting
12181186
example: "1815-12-10T18:43:00.271152Z"
12191187
type: string
1220-
deletedAt:
1221-
description: Time the resource was marked as deleted
1222-
example: "2022-04-22T21:01:05.058161Z"
1223-
type: string
12241188
destinationAccountId:
12251189
description: ID of the destination account
12261190
example: 8e16b456-a719-48ce-9fec-e115cfa7cbcc

internal/controllers/v4/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ func GetAccountRecentEnvelopes(c *gin.Context) {
283283
// Get the Envelope IDs for the 50 latest transactions
284284
latest := models.DB.
285285
Model(&models.Transaction{}).
286-
Joins("LEFT JOIN envelopes ON envelopes.id = transactions.envelope_id AND envelopes.deleted_at IS NULL").
286+
Joins("LEFT JOIN envelopes ON envelopes.id = transactions.envelope_id").
287287
Select("envelopes.id as e_id, envelopes.name as name, datetime(envelopes.created_at) as created, envelopes.archived as archived").
288288
Where(&models.Transaction{
289289
DestinationAccountID: account.ID,

internal/models/account.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ func (a Account) RecentEnvelopes(db *gorm.DB) ([]*uuid.UUID, error) {
239239
// Get the Envelope IDs for the 50 latest transactions
240240
latest := db.
241241
Model(&Transaction{}).
242-
Joins("LEFT JOIN envelopes ON envelopes.id = transactions.envelope_id AND envelopes.deleted_at IS NULL").
242+
Joins("LEFT JOIN envelopes ON envelopes.id = transactions.envelope_id").
243243
Select("envelopes.id as e_id, datetime(envelopes.created_at) as created").
244244
Where(&Transaction{
245245
DestinationAccountID: a.ID,

internal/models/budget.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ func (b Budget) Income(db *gorm.DB, month types.Month) (income decimal.Decimal,
5555
var transactions []Transaction
5656

5757
err = db.
58-
Joins("JOIN accounts source_account ON transactions.source_account_id = source_account.id AND source_account.deleted_at IS NULL").
59-
Joins("JOIN accounts destination_account ON transactions.destination_account_id = destination_account.id AND destination_account.deleted_at IS NULL").
58+
Joins("JOIN accounts source_account ON transactions.source_account_id = source_account.id").
59+
Joins("JOIN accounts destination_account ON transactions.destination_account_id = destination_account.id").
6060
Joins("JOIN budgets ON source_account.budget_id = budgets.id").
6161
Where("source_account.on_budget = false AND destination_account.on_budget = true").
6262
Where("destination_account.external = 0").
@@ -80,9 +80,9 @@ func (b Budget) Income(db *gorm.DB, month types.Month) (income decimal.Decimal,
8080
func (b Budget) Allocated(db *gorm.DB, month types.Month) (allocated decimal.Decimal, err error) {
8181
var monthConfigs []MonthConfig
8282
err = db.
83-
Joins("JOIN envelopes ON month_configs.envelope_id = envelopes.id AND envelopes.deleted_at IS NULL").
84-
Joins("JOIN categories ON envelopes.category_id = categories.id AND categories.deleted_at IS NULL").
85-
Joins("JOIN budgets ON categories.budget_id = budgets.id AND budgets.deleted_at IS NULL").
83+
Joins("JOIN envelopes ON month_configs.envelope_id = envelopes.id").
84+
Joins("JOIN categories ON envelopes.category_id = categories.id").
85+
Joins("JOIN budgets ON categories.budget_id = budgets.id").
8686
Where("budgets.id = ?", b.ID).
8787
Where("month_configs.month >= date(?)", month).
8888
Where("month_configs.month < date(?)", month.AddDate(0, 1)).

0 commit comments

Comments
 (0)