@@ -19,6 +19,11 @@ or some other migration tool to manage this part of the database's life-cycle.
19
19
20
20
v3 has been released, please upgrade when possible, v2 is on life support only now.
21
21
22
+ # Note on v3 vs v4
23
+
24
+ v4 is identical virtually identical to v3 (it has 1 or 2 more features) but
25
+ was turned into modules.
26
+
22
27
## Why another ORM
23
28
24
29
While attempting to migrate a legacy Rails database, we realized how much ActiveRecord benefited us in terms of development velocity.
@@ -111,6 +116,7 @@ Table of Contents
111
116
- Strongly typed querying (usually no converting or binding to pointers)
112
117
- Hooks (Before/After Create/Select/Update/Delete/Upsert)
113
118
- Automatic CreatedAt/UpdatedAt
119
+ - Automatic DeletedAt
114
120
- Table and column whitelist/blacklist
115
121
- Relationships/Associations
116
122
- Eager loading (recursive)
@@ -399,18 +405,22 @@ sqlboiler psql
399
405
Flags:
400
406
--add-global-variants Enable generation for global variants
401
407
--add-panic-variants Enable generation for panic variants
408
+ --add-soft-deletes Enable soft deletion by updating deleted_at timestamp
402
409
-c, --config string Filename of config file to override default lookup
403
410
-d, --debug Debug mode prints stack traces on error
404
411
-h, --help help for sqlboiler
405
412
--no-auto-timestamps Disable automatic timestamps for created_at/updated_at
413
+ --no-back-referencing Disable back referencing in the loaded relationship structs
406
414
--no-context Disable context.Context usage in the generated code
415
+ --no-driver-templates Disable parsing of templates defined by the database driver
407
416
--no-hooks Disable hooks feature for your models
408
417
--no-rows-affected Disable rows affected in the generated API
409
418
--no-tests Disable generated go test files
410
419
-o, --output string The name of the folder to output to (default "models")
411
420
-p, --pkgname string The name you wish to assign to your generated package (default "models")
412
- --struct-tag-casing string Decides the casing for go structure tag names. camel or snake (default "snake")
421
+ --struct-tag-casing string Decides the casing for go structure tag names. camel, title or snake (default snake) (default "snake")
413
422
-t, --tag strings Struct tags to be included on your models in addition to json, yaml, toml
423
+ --tag-ignore strings List of column names that should have tags values set to '-' (ignored during parsing)
414
424
--templates strings A templates directory, overrides the bindata'd template folders in sqlboiler
415
425
--version Print the version
416
426
--wipe Delete the output folder (rm -rf) before generation to ensure sanity
@@ -840,6 +850,10 @@ The most common causes of problems and panics are:
840
850
field in Go so sqlboiler assumes you do not want to insert that field and you want the default
841
851
value from the database. Use a whitelist/greylist to add that field to the list of fields
842
852
to insert.
853
+ - decimal library showing errors like: ` pq: encode: unknown type types.NullDecimal `
854
+ is a result of a too-new and broken version of the github.com/ericlargergren/decimal
855
+ package, use the following version in your go.mod:
856
+ github.com/ericlagergren/decimal v0.0.0-20181231230500-73749d4874d5
843
857
844
858
For errors with other causes, it may be simple to debug yourself by looking at the generated code.
845
859
Setting ` boil.DebugMode ` to ` true ` can help with this. You can change the output using ` boil.DebugWriter ` (defaults to ` os.Stdout ` ).
@@ -976,6 +990,23 @@ before being sent to the database (if they were going to be sent).
976
990
will be used. To set ` created_at ` to ` null ` , set ` Valid ` to false and ` Time ` to a non-zero value.
977
991
* The ` updated_at ` column will always be set to ` time.Now() ` .
978
992
993
+ ### Automatic DeletedAt (Soft Delete)
994
+
995
+ Soft deletes are a way of deleting records in a database for the average query
996
+ without actually removing the data. This type of thing is important in certain
997
+ scenarios where data retention is important. It is typically done by adding a
998
+ ` deleted ` bool or a ` deleted_at ` timestamp to each table in the database
999
+ that can be soft deleted and subsequent queries on that table should always
1000
+ make sure that ` deleted != true ` or ` deleted_at is null ` to prevent showing
1001
+ "deleted" data.
1002
+
1003
+ SQLBoiler uses the ` deleted_at ` variant to provide this functionality. If your
1004
+ table has a nullable timestamp field named ` deleted_at ` it will be a candidate
1005
+ for soft-deletion.
1006
+
1007
+ * NOTE* : As of writing soft-delete is opt-in via ` --add-soft-deletes ` and is
1008
+ liable to change in future versions.
1009
+
979
1010
### Query Building
980
1011
981
1012
We generate "Starter" methods for you. These methods are named as the plural versions of your model,
0 commit comments