Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEFAULT values are not migrated. #78

Open
Sahaquielxo opened this issue Jun 14, 2018 · 5 comments
Open

DEFAULT values are not migrated. #78

Sahaquielxo opened this issue Jun 14, 2018 · 5 comments
Assignees

Comments

@Sahaquielxo
Copy link

Hi, once more issue.
MySQL table:

| CREATE TABLE `rates_v2` (
  `host` varchar(20) NOT NULL,
  `rate` varchar(20) NOT NULL DEFAULT '',
  `added` datetime DEFAULT NULL,
  `new` set('N','Y') DEFAULT 'Y',
  `longweek` datetime DEFAULT NULL,
  `longmonth` datetime DEFAULT NULL,
  `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  `hostId` tinyint(3) unsigned NOT NULL DEFAULT '1',
  `foreign_key` set('N','Y') DEFAULT 'Y',
  PRIMARY KEY (`host`,`hostId`,`rate`),
  KEY `Host` (`hostId`),
  KEY `rateTableNameIndex` (`new`,`rate`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
r=> \d+ rates_v2;
                                             Table "rates_v2"
   Column    |            Type             | Collation | Nullable | Default | Storage  | Stats target | Description
-------------+-----------------------------+-----------+----------+---------+----------+--------------+-------------
 host        | character varying(20)       |           | not null |         | extended |              |
 rate        | character varying(20)       |           | not null |         | extended |              |
 added       | timestamp without time zone |           |          |         | plain    |              |
 new         | text                        |           |          |         | extended |              |
 longweek    | timestamp without time zone |           |          |         | plain    |              |
 longmonth   | timestamp without time zone |           |          |         | plain    |              |
 updated     | timestamp without time zone |           | not null |         | plain    |              |
 hostId      | integer                     |           | not null |         | plain    |              |
 foreign_key | text                        |           |          |         | extended |              |

As you can see, for the row updated, DEFAULT value CURRENT_TIMESTAMP from MySQL did not migrated into PostgreSQL.

If chameleon is able to resolve this issue right now, or I have to wait for new release?
Thanks for answer.

@the4thdoctor
Copy link
Owner

hi, I'm fairly sure I decided to not set the default values on purpose and trust the data coming from the mysql replica.
I can check if this can cause problems and eventually fix the issue.

Many thanks for the report.

@the4thdoctor
Copy link
Owner

I've tested the functionality and the default values are correctly determined by mysql.
However I'll think a way to add the default values on the postgres tables (thinking of a migration scenario).

Regarding the ticket #74 I can't add the functionality until the replication library returns the data as string '0000-00-00 00:00:00'.
I've added a reference to a PR I'm waiting to be merged.

Thanks

@grepsedawk
Copy link

As far as I can tell, default values are still not transferred to psql
For our migration, I think I'll write a bulk default migration within my rails app

@timkrins
Copy link

I also came across this today while using a replicated database after running chameleon detach_replica.
It seems everything comes across absolutely fine - all except the default values.

@bomuva
Copy link

bomuva commented Oct 27, 2022

Definition of default value for table column still not replicated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants