Commit 2e91e8d
authored
Improve migration support using
This PR improves migration support by using the `CREATE INDEX ASYNC`
syntax in `schema.py`.
Changes extracted and modified from #46.
By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.
The changes are detailed below.
### `sql_create_index`
Previously defined as:
```python
sql_create_index = (
"CREATE INDEX %(name)s ON %(table)s%(using)s "
"(%(columns)s)%(include)s%(extra)s%(condition)s"
)
```
Now defined as:
```python
sql_create_index = (
"CREATE INDEX ASYNC %(name)s ON %(table)s%(using)s "
"(%(columns)s)%(include)s%(extra)s%(condition)s"
)
```
This matches the syntax defined by [Asynchronous indexes in Aurora
DSQL](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-create-index-async.html).
### `sql_create_unique`
Previously defined as:
```python
sql_create_unique = (
"ALTER TABLE %(table)s ADD CONSTRAINT %(name)s "
"UNIQUE%(nulls_distinct)s (%(columns)s)%(deferrable)s"
)
```
Now defined as:
```python
sql_create_unique = "CREATE UNIQUE INDEX ASYNC %(name)s ON %(table)s (%(columns)s)"
```
This avoids the `ALTER TABLE ... ADD CONSTRAINT` syntax which is not
supported by DSQL according to [Supported subsets of SQL commands in
Aurora
DSQL](https://docs.aws.amazon.com/aurora-dsql/latest/userguide/working-with-postgresql-compatibility-supported-sql-subsets.html#alter-table-syntax-support).
### General cleanup
As part of this change I added some more documentation, and reorganized
the position of a few definitions to better isolate concepts. This will
make upcoming changes simpler too thanks to the improved consistency.CREATE INDEX ASYNC (#47)1 parent c5520e7 commit 2e91e8d
2 files changed
+24
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 | | |
30 | | - | |
31 | | - | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
32 | 41 | | |
33 | | - | |
34 | | - | |
| 42 | + | |
35 | 43 | | |
36 | 44 | | |
37 | | - | |
38 | | - | |
| 45 | + | |
39 | 46 | | |
40 | 47 | | |
41 | 48 | | |
42 | 49 | | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
| 50 | + | |
| 51 | + | |
47 | 52 | | |
48 | | - | |
| 53 | + | |
49 | 54 | | |
50 | 55 | | |
51 | | - | |
52 | 56 | | |
53 | | - | |
54 | 57 | | |
55 | 58 | | |
56 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
16 | 20 | | |
17 | 21 | | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
21 | 25 | | |
22 | 26 | | |
23 | | - | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
0 commit comments