Foreign keys - Schema Synchronization #17338
Unanswered
DanielDamantia
asked this question in
Q&A
Replies: 2 comments
-
Howdy! What's the Bytebase version and database engine type? Will be great if you could share the schema - one with foreign key, and the other without it? |
Beta Was this translation helpful? Give feedback.
0 replies
-
Howdy! Thanks for following up.
* Bytebase version: 3.9.1 Community Edition
* Database engine: MySQL 8.0.39
The issue happens when synchronizing schemas directly: foreign keys do not appear in the synced schema. Here’s a real example:
- Schema from database dump (with FKs):
CREATE TABLE `DMNT_ClientData` (
`Id` int NOT NULL AUTO_INCREMENT,
`ClientRef` char(50) COLLATE latin1_bin NOT NULL,
`Type` char(50) CHARACTER SET latin1 COLLATE latin1_bin NOT NULL,
`Value` varchar(1000) COLLATE latin1_bin NOT NULL,
`Status` enum('Activated','Archived','Deleted') COLLATE latin1_bin NOT NULL,
`CreatedBy` char(50) COLLATE latin1_bin NOT NULL,
`Created` timestamp NOT NULL,
`ModifiedBy` char(50) COLLATE latin1_bin NOT NULL,
`Modified` timestamp NOT NULL,
PRIMARY KEY (`Id`),
UNIQUE KEY `DMNT_ClientData_UNIQUE` (`ClientRef`,`Type`),
KEY `DMNT_ClientData_DMNT_Users_FK` (`CreatedBy`),
KEY `DMNT_ClientData_DMNT_Users_FK_1` (`ModifiedBy`),
KEY `DMNT_ClientData_DMNT_ClientDataType_FK` (`Type`),
CONSTRAINT `DMNT_ClientData_DMNT_ClientDataType_FK` FOREIGN KEY (`Type`) REFERENCES `DMNT_ClientDataTypes` (`Ref`),
CONSTRAINT `DMNT_ClientData_DMNT_Clients_FK` FOREIGN KEY (`ClientRef`) REFERENCES `DMNT_Clients` (`Ref`),
CONSTRAINT `DMNT_ClientData_DMNT_Users_FK` FOREIGN KEY (`CreatedBy`) REFERENCES `DMNT_Users` (`Ref`),
CONSTRAINT `DMNT_ClientData_DMNT_Users_FK_1` FOREIGN KEY (`ModifiedBy`) REFERENCES `DMNT_Users` (`Ref`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
…-Schema after Bytebase synchronization (missing FKs):
CREATE TABLE `DMNT_ClientData` (
`Id` int NOT NULL AUTO_INCREMENT,
`ClientRef` char(50) NOT NULL,
`Type` char(50) NOT NULL,
`Value` varchar(1000) NOT NULL,
`Status` enum('Activated','Archived','Deleted') NOT NULL,
`CreatedBy` char(50) NOT NULL,
`Created` timestamp NOT NULL,
`ModifiedBy` char(50) NOT NULL,
`Modified` timestamp NOT NULL,
PRIMARY KEY (`Id`),
KEY `DMNT_ClientData_DMNT_ClientDataType_FK` (`Type`),
KEY `DMNT_ClientData_DMNT_Users_FK` (`CreatedBy`),
KEY `DMNT_ClientData_DMNT_Users_FK_1` (`ModifiedBy`),
UNIQUE KEY `DMNT_ClientData_UNIQUE` (`ClientRef`, `Type`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_bin;
As you can see, all the FOREIGN KEY constraints are lost during synchronization.
Is this the expected behavior, or is it a bug/limitation?
Thanks a lot for your support!
From: Danny Xu ***@***.***>
Sent: martes, 2 de septiembre de 2025 17:09
To: bytebase/bytebase ***@***.***>
Cc: Daniel Galán Ahumada ***@***.***>; Author ***@***.***>
Subject: Re: [bytebase/bytebase] Foreign keys - Schema Synchronization (Discussion #17338)
Howdy! What's the Bytebase version and database engine type? Will be great if you could share the schema - one with foreign key, and the other without it?
—
Reply to this email directly, view it on GitHub<#17338 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/BJ66R6QFHCCBRG4O4JVLXUD3QWXJ7AVCNFSM6AAAAACFNTBDMSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTIMRYGY4DOMY>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi Bytebase team,
I’m using the Community edition and it’s been working great so far, very useful. However, I’ve noticed an issue: when synchronizing schemas across different environments, foreign keys are not being compared or transferred.
Is this the expected behavior, or could it be a limitation/bug? This feature is the only missing piece for us to achieve smooth integrations.
Thanks a lot for your support!
Beta Was this translation helpful? Give feedback.
All reactions