-
-
Save mojzis/3077e699efa0d8de1c4e5833266b02b6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- generate alter table to change default values on columns from previous MySQL version | |
select | |
-- TABLE_NAME, COLUMN_NAME, | |
-- column_type, | |
concat('ALTER TABLE ', table_name, ' CHANGE ', COLUMN_NAME, ' ', COLUMN_NAME, ' ', column_type,' NOT NULL DEFAULT ',if( COLUMN_DEFAULT = '0000-00-00', "'1000-01-01';", "'1000-01-01 00:00:00';")) alt | |
from information_schema.columns | |
where table_schema = 'sourcedb' | |
and COLUMN_DEFAULT in ('0000-00-00 00:00:00', '0000-00-00') | |
order by table_name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment