node-database-cleaner icon indicating copy to clipboard operation
node-database-cleaner copied to clipboard

Make mysql work for some special cases (database case, views, foreign keys)

Open eric-p-hutchins opened this issue 8 years ago • 3 comments

Currently in MySQL if lower_case_table_names is set to 2 then when your database name has an uppercase character database-cleaner will fail because the show tables query returns using a column of Tables_in_<lowercase DB name>

Also, if you have views, it will fail.

Also, if any tables have foreign key constraints, it will fail.

  • Check the value of lower_case_table_names and if it is 2 then lowercasing the database name when constructing the expected column name seems to fix it.

  • Exclude views when getting table names to truncate so that it doesn't error on them.

  • Disable foreign key checks so that it doesn't fail on them

eric-p-hutchins avatar Feb 28 '17 18:02 eric-p-hutchins

Hi @hutchiep190,

I just reviewed your PR. It's a good improvement to the library.

Can you please add some tests to the scenários you are covering so I can integrate quickly?

Cheers,

Emerson

emerleite avatar May 23 '17 13:05 emerleite

@emerleite Hi,

I was using your package for my tests when I came across Foreign Key Checks. I guess any good mysql db would have foreign key checks enabled. Are you by any chance active on this repo ? Even if you are not, would you mind accepting and merging a PR with the changes ?

palashjhabak avatar Aug 23 '18 15:08 palashjhabak

Hi @palashjhabak. I just need to checkit agian to see if not breaks anything.

emerleite avatar Nov 20 '18 13:11 emerleite