Skip to content

Commit 23148db

Browse files
akashthawaitcctaherkltaherklVivekY1098
authored
Documentation for check constraints (#980)
* verification API and dump flow changes to support MySQL CHECK CONSTRAINTS (#978) (#30) * verification ap and dump flow changes * fixed IT issue * Check constraints verificartion api v2 (#24) * handled function not found * added unhandled error * updated the error msg --------- * fix IT issue * comment addressed (#27) * comment addressed 1. rename the functionNotFound 2. added condition to call verification api * spell checked --------- * refactor the DbDumpImpl struct (#28) * refactor the DbDumpImpl struct * remove the GenerateCheckConstrainstExprId method --------- * fixed if condition --------- Co-authored-by: Taher Lakdawala <78196491+taherkl@users.noreply.github.com> Co-authored-by: taherkl <taher.lakdawala@ollion.com> Co-authored-by: Vivek Yadav <vivek.yadav@ollion.com> Co-authored-by: Vivek Yadav <105432992+VivekY1098@users.noreply.github.com> * added doc for check constraints 1. added documentation for check constraints * formatting changes (#32) * Updated docs (#40) * formatting changes * Check constraint doc cmt (#37) * added ss for issues also * updated the text * updated the text * Update mysql.md * updated the text --------- Co-authored-by: Vivek Yadav <vivek.yadav@ollion.com> Co-authored-by: Akash Thawait <aakash@ollion.com> --------- Co-authored-by: Vivek Yadav <105432992+VivekY1098@users.noreply.github.com> Co-authored-by: Vivek Yadav <vivek.yadav@ollion.com> * Check constraint doc cmt (#46) * formatting changes * added ss for issues also * updated the text * updated the text * Update mysql.md * updated the text * updated the faq --------- Co-authored-by: Akash Thawait <aakash@ollion.com> Co-authored-by: Vivek Yadav <vivek.yadav@ollion.com> * Rephrased document --------- Co-authored-by: Taher Lakdawala <78196491+taherkl@users.noreply.github.com> Co-authored-by: taherkl <taher.lakdawala@ollion.com> Co-authored-by: Vivek Yadav <vivek.yadav@ollion.com> Co-authored-by: Vivek Yadav <105432992+VivekY1098@users.noreply.github.com>
1 parent 6892b44 commit 23148db

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed

docs/data-types/mysql.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ and `ON UPDATE` actions, we drop them.
142142
While Spanner supports default values, Spanner migration tool currently does not support translating source `DEFAULT` constraints to Spanner `DEFAULT` constraints. We drop the `DEFAULT` MySQL constraint during conversion.
143143
It can be manually added to the DDL via an `ALTER TABLE` command.
144144

145+
## Check Constraints
146+
147+
While Spanner supports check constraints, the Spanner migration tool currently migrates all valid check constraints from MySQL to Spanner.
148+
149+
While moving from schema to prepare migration phase, if any invalid or unsupported check constraints are identified, the migration process will be halted and will not commence. This is to ensure the integrity and accuracy of the migration. Any identified issues will be clearly displayed in the Issues & Suggestions tab. This allows the user to review all errors in detail. The user will then have the opportunity to manually address these errors by either correcting the invalid check constraints or removing them altogether. This step is crucial to ensure that all constraints are compatible with the target system, thereby preventing potential issues during or after the migration process. Once the necessary corrections have been made, the user can proceed to re-initiate the migration process without any unsupported constraints.
150+
151+
> Note: As check constraints were introduced with MySQL version 8.0.16, the Spanner migration tool will automatically include these constraints in the Spanner draft for databases using this version or later. For MySQL versions prior to 8.0.16, where check constraints are not supported, users will need to manually incorporate any required check constraints into the Spanner draft. This approach ensures that all necessary constraints are accurately represented in the Spanner environment, tailored to the specific needs of the database.
152+
145153
## Secondary Indexes
146154

147155
The tool maps MySQL secondary indexes to Spanner secondary indexes, and preserves

docs/limitations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Please refer to the [issues section](https://github.com/GoogleCloudPlatform/span
2424

2525
- Schema Only Mode does not create foreign keys
2626
- Foreign key actions such as [ON DELETE CASCADE](https://cloud.google.com/spanner/docs/reference/standard-sql/data-definition-language#create_table) are not supported. If you do not specify a foreign key action, Spanner infers NO ACTION as the default action
27-
- Migration of check constraints, functions and views is not supported
27+
- Migration of functions and views is not supported
2828
- Schema recommendations are based on static analysis of the schema only
2929
- PG Spanner dialect support is limited, and is not currently available on the UI
3030

docs/troubleshoot/faq.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ To bring up the Spanner Migration Tool UI, please follow the steps mentioned [he
2525

2626
### Can Spanner Migration Tool be used without connecting to the spanner instance?
2727

28-
Yes, Spanner Migration Tool can be used for schema assessment and modifications without connecting to the spanner instance
28+
No, the Spanner Migration Tool cannot be used for schema assessment and modification without connecting to a Spanner instance. Support for default values and check constraints has been added, and this feature requires validation of DML, which means the Spanner instance must be up and running.
2929

3030
### When is a table interleavable?
3131

docs/ui/schema-conv/issues.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ nav_order: 3
99
# Issues and Suggestions
1010
{: .no_toc }
1111

12-
Spanner migration tool scans through the generated spanner schema and notifies the user of any warnings encountered. It also makes intelligent suggestions to the user which would help them utilize the spanner capabilities to the fullest.
12+
Spanner migration tool scans through the generated spanner schema and notifies the user of any warnings or errors encountered. It also makes intelligent suggestions to the user which would help them utilize the spanner capabilities to the fullest.
1313

1414
<details open markdown="block">
1515
<summary>
@@ -29,6 +29,15 @@ Spanner migration tool scans through the generated spanner schema and notifies t
2929
- [Hotspotting](https://cloud.google.com/spanner/docs/schema-design) due to timestamp or auto-increment keys
3030
- Auto Increment has been converted to Sequence, set Ignore Range or Start with Counter to avoid duplicate value errors
3131

32+
## Errors
33+
34+
- Detection of unsupported check constraints in spanner.
35+
- Data type mismatch of referenced column in check constraints.
36+
- Referenced column in check constraints not found.
37+
- Function referenced in check constraints is not found.
38+
39+
![](https://services.google.com/fh/files/misc/cc5.png)
40+
3241
## Suggestions
3342

3443
- Modifications related to converting a table into an interleaved one

docs/ui/schema-conv/schema-conv.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ In the configure schema page, the user can view details of the source database a
1919
1. Primary Key
2020
1. Foreign Key
2121
1. Interleave
22+
1. Check Constraints
2223
1. SQL
2324
1. Index details
2425
1. Sequence Details (Only for Source DB MySql)

docs/ui/schema-conv/spanner-draft.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@ To interleave a `child table` within a `parent table`, the following conditions
8686

8787
4. Use the modified session file in the [SMT commands](../../cli/cli.md) or it can be imported via [SMT UI](../connect-source.md#load-session-file) and proceed further.
8888

89+
### Check Constraints
90+
Users have the ability to view and modify check constraints of a table via the check constraints tab. They can alter the check constraint's name, condition, and even remove the check constraint entirely. Once these changes are made the [session file](../ui.md/#termsterminology) is updated.
91+
92+
![](https://services.google.com/fh/files/misc/cc3.png)
93+
94+
#### Add or Edit Constraint
95+
Besides modifying the existing check constraint in the Spanner draft mapped from the source database, users can also add new constraints to the selected table.
96+
97+
![](https://services.google.com/fh/files/misc/cc2.png)
98+
99+
![](https://services.google.com/fh/files/misc/cc1.png)
100+
101+
#### Remove Constraint
102+
In addition to adding check constraints, users can also remove the check constraints in the spanner draft for the selected table.
103+
104+
![](https://services.google.com/fh/files/misc/cc4.png)
89105

90106
### SQL
91107

0 commit comments

Comments
 (0)