Skip to content

Commit

Permalink
docs: Clarify rules for quoting string literals (#212)
Browse files Browse the repository at this point in the history
Update the documentation to clarify how to specify default values for
the add column and create table operations.
  • Loading branch information
andrew-farries authored Dec 5, 2023
1 parent 3924fd0 commit 6d648e7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -716,12 +716,15 @@ An add column operation creates a new column on an existing table.
}
```

Default values are subject to the usual rules for quoting SQL expressions. In particular, string literals should be surrounded with single quotes.

Example **add column** migrations:

* [03_add_column.json](../examples/03_add_column.json)
* [06_add_column_to_sql_table.json](../examples/06_add_column_to_sql_table.json)
* [17_add_rating_column.json](../examples/17_add_rating_column.json)
* [26_add_column_with_check_constraint.json](../examples/26_add_column_with_check_constraint.json)
* [30_add_column_simple_up.json](../examples/30_add_column_simple_up.json)

### Alter column

Expand Down Expand Up @@ -924,6 +927,8 @@ where each `column` is defined as:
},
```

Default values are subject to the usual rules for quoting SQL expressions. In particular, string literals should be surrounded with single quotes.

Example **create table** migrations:

* [01_create_tables.json](../examples/01_create_tables.json)
Expand Down
16 changes: 16 additions & 0 deletions examples/30_add_column_simple_up.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "30_add_column_simple_up",
"operations": [
{
"add_column": {
"table": "people",
"up": "'temporary-description'",
"column": {
"name": "description",
"type": "varchar(255)",
"nullable": false
}
}
}
]
}

0 comments on commit 6d648e7

Please sign in to comment.