Skip to content

Commit

Permalink
Documentation for check constraints (#980)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
5 people authored Jan 9, 2025
1 parent 6892b44 commit 23148db
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 3 deletions.
8 changes: 8 additions & 0 deletions docs/data-types/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,14 @@ and `ON UPDATE` actions, we drop them.
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.
It can be manually added to the DDL via an `ALTER TABLE` command.

## Check Constraints

While Spanner supports check constraints, the Spanner migration tool currently migrates all valid check constraints from MySQL to Spanner.

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.

> 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.
## Secondary Indexes

The tool maps MySQL secondary indexes to Spanner secondary indexes, and preserves
Expand Down
2 changes: 1 addition & 1 deletion docs/limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Please refer to the [issues section](https://github.com/GoogleCloudPlatform/span

- Schema Only Mode does not create foreign keys
- 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
- Migration of check constraints, functions and views is not supported
- Migration of functions and views is not supported
- Schema recommendations are based on static analysis of the schema only
- PG Spanner dialect support is limited, and is not currently available on the UI

Expand Down
2 changes: 1 addition & 1 deletion docs/troubleshoot/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ To bring up the Spanner Migration Tool UI, please follow the steps mentioned [he

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

Yes, Spanner Migration Tool can be used for schema assessment and modifications without connecting to the spanner instance
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.

### When is a table interleavable?

Expand Down
11 changes: 10 additions & 1 deletion docs/ui/schema-conv/issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ nav_order: 3
# Issues and Suggestions
{: .no_toc }

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.
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.

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

## Errors

- Detection of unsupported check constraints in spanner.
- Data type mismatch of referenced column in check constraints.
- Referenced column in check constraints not found.
- Function referenced in check constraints is not found.

![](https://services.google.com/fh/files/misc/cc5.png)

## Suggestions

- Modifications related to converting a table into an interleaved one
Expand Down
1 change: 1 addition & 0 deletions docs/ui/schema-conv/schema-conv.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ In the configure schema page, the user can view details of the source database a
1. Primary Key
1. Foreign Key
1. Interleave
1. Check Constraints
1. SQL
1. Index details
1. Sequence Details (Only for Source DB MySql)
Expand Down
16 changes: 16 additions & 0 deletions docs/ui/schema-conv/spanner-draft.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@ To interleave a `child table` within a `parent table`, the following conditions

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.

### Check Constraints
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.

![](https://services.google.com/fh/files/misc/cc3.png)

#### Add or Edit Constraint
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.

![](https://services.google.com/fh/files/misc/cc2.png)

![](https://services.google.com/fh/files/misc/cc1.png)

#### Remove Constraint
In addition to adding check constraints, users can also remove the check constraints in the spanner draft for the selected table.

![](https://services.google.com/fh/files/misc/cc4.png)

### SQL

Expand Down

0 comments on commit 23148db

Please sign in to comment.