doutorfinancas / go-mad Goto Github PK
View Code? Open in Web Editor NEWGo MySQL Anonymized Dump
License: Apache License 2.0
Go MySQL Anonymized Dump
License: Apache License 2.0
Hi, when triggers are dumped (#40) .. they can not be imported using the mysql cli as they contain the current mysql delimiter ;
.
For example a dumped trigger looks like this:
--
-- Trigger `upd_check`
--
CREATE TRIGGER upd_check BEFORE UPDATE ON account
FOR EACH ROW
BEGIN
IF NEW.amount < 0 THEN
SET NEW.amount = 0;
ELSEIF NEW.amount > 100 THEN
SET NEW.amount = 100;
END IF;
END;
Which fails on the ;
within the trigger -- within the IF statement.
According to the mysql documentation the delimiter needs to be changed to allow for this.
if you use the mysql program to define a trigger that executes multiple statements, it is necessary to redefine the mysql statement delimiter so that you can use the ; statement delimiter within the trigger definition. -- https://dev.mysql.com/doc/refman/5.7/en/trigger-syntax.html
So a trigger dump should maybe look like this:
--
-- Trigger `upd_check`
--
delimiter //
CREATE TRIGGER upd_check BEFORE UPDATE ON account
FOR EACH ROW
BEGIN
IF NEW.amount < 0 THEN
SET NEW.amount = 0;
ELSEIF NEW.amount > 100 THEN
SET NEW.amount = 100;
END IF;
END;//
delimiter ;
Then the dump can get imported.
With more than one trigger can wrap all triggers with:
delimiter //
-- triggers; each ending in //
delimiter ;
We use the shopware-cli tool (which uses this library) for creating a dev seed shared between devs and are having to rewrite the seed to accommodate for this.
--
MySQL Version: Server version: 5.7.40 MySQL Community Server (GPL)
CREATE TABLE `product_keyword_dictionary` (
`id` binary(16) NOT NULL,
`language_id` binary(16) NOT NULL,
`keyword` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
`reversed` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci GENERATED ALWAYS AS (reverse(`keyword`)) STORED,
PRIMARY KEY (`id`,`language_id`),
UNIQUE KEY `uniq.language_id_keyword` (`language_id`,`keyword`),
KEY `idx.product_keyword_dictionary.language_id` (`language_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
ERROR 3105 (HY000) at line 11000: The value specified for generated column 'reversed' in table 'product_keyword_dictionary' is not allowed.
Maybe we should generate a griped sql file at the end, as the file size can be huge
INSERT INTO `user` (`id`, 'faker.Person.Name()' AS `username`)
It looks like rewritemap is applied too early
Hey,
we use for all tables UUIDs saved in binary(16). Those fields should be hexed in the output SQL
Currently, the rewrite feature replaces all rows with the value. I guess that hurts the reproducibility of bugs as the data is not the same.
My idea would be to change the SELECT to IF(colum IS NULL, NULL, REPLACEMNET) as X
. With a new option.
What do you think about that? I could provide a PR
Currently, the only way to see what it is doing is to run SHOW processlist
in another terminal.
Make we could add a progress bar which table is currently worked on ๐
First thanks for building this โค๏ธ
I understand from the description that is creating for any record an own INSERT INTO
. Does it maybe make more sense to have an insert into row limiter rather than. like --insert-into-limit=50
adds only 50 records to insert into
And I would like to embed this into a cli command
When you try to animalize a column with a camelcase header it will not be found, it has to be lowercase. It would be nice if someone can change it so you can animalize columns with camelcase and lowercase
Hey,
when the Database contains Database Triggers the output SQL does not contain triggers
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.