Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

MySQL database backup with foreign keys #2081

Closed
jwensley2 opened this Issue Dec 18, 2012 · 1 comment

Comments

Projects
None yet
3 participants
Contributor

jwensley2 commented Dec 18, 2012

When using dbutil->backup() on a MySQL database that has foreign keys it causes problems when importing since the tables that the foreign keys go to may not exist yet.

Doing a mysqldump or using something like sequal pro usually adds options to disable foreign key checks like.

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

I think it would make sense for the backup method to add this in when generating the backups.

Contributor

cryode commented Dec 19, 2012

Sounds like a good idea. Why don't you submit a pull request with the change?

@narfbg narfbg closed this in 4851217 Dec 20, 2012

@narfbg narfbg added a commit that referenced this issue Dec 20, 2012

@narfbg narfbg Merge pull request #2087 from AndrewPodner/develop
Resolves issue #2081 : Foreign Key Checks
16c26ff

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

@AndrewPodner AndrewPodner Resolves issue #2081 : provides an option to include statements to di…
…sable and re-enable foreign key checks in a MySQL database backup output statement.
713899c

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

@AndrewPodner AndrewPodner fixes #2081 : change parameter/variable name to 'foreign_key_checks',…
… update change log

Signed-off-by:Andrew Podner <a.podner@me.com>
1d3ef68

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

@AndrewPodner AndrewPodner fixes #2081 : fix change log entry
Signed-off-by:Andrew Podner <a.podner@me.com>
9631749

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

@narfbg narfbg Merge pull request #2087 from AndrewPodner/develop
Resolves issue #2081 : Foreign Key Checks
12d7361
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment