--not-null-default and not_null_default=, refs #24

This commit is contained in:
Simon Willison 2019-06-12 18:35:02 -07:00
commit 2fed87da6e
7 changed files with 87 additions and 16 deletions

View file

@ -280,6 +280,10 @@ You can explicitly specify the column you wish to reference using ``--fk-col``::
$ sqlite-utils add-column mydb.db dogs species_id --fk species --fk-col ref
You can set a ``NOT NULL DEFAULT 'x'`` constraint on the new column using ``--not-null-default``::
$ sqlite-utils add-column mydb.db dogs friends_count integer --not-null-default 0
.. _cli_add_column_alter:
Adding columns automatically on insert/update

View file

@ -284,6 +284,12 @@ You can explicitly specify the column you wish to reference using ``fk_col``:
db["dogs"].add_column("species_id", fk="species", fk_col="ref")
You can set a ``NOT NULL DEFAULT 'x'`` constraint on the new column using ``not_null_default``:
.. code-block:: python
db["dogs"].add_column("friends_count", int, not_null_default=0)
.. _python_api_add_column_alter:
Adding columns automatically on insert/update