Database soft deletes
In LiteFarm, we almost always use “soft deletes”. This means that when a user “deletes” data in the app what’s actually happening is we’re setting a flag in the database that says that data is now deleted, e.g. deleted = true.
See below for a list of tables with a deleted
column to support soft deletes.
When working with raw SQL queries, be sure to include a WHERE clause with the condition deleted = FALSE
.
When working with Objection.js models, use the whereNotDeleted()
method in your query chain. See the documentation for this plugin for details.
Tables with a deleted
field
crop
crop_variety
disease
document
farm
farmExpense
farmExpenseType
fertilizer
location
management_plan
notification
notification_user
organic_history
organicCertifierSurvey
pesticide
price
product
role
sale
shift
shiftTask
supportTicket
task
task_type
yield