{"action":"created","issue":{"url":"https://api.github.com/repos/dimitri/pgloader/issues/141","repository_url":"https://api.github.com/repos/dimitri/pgloader","labels_url":"https://api.github.com/repos/dimitri/pgloader/issues/141/labels{/name}","comments_url":"https://api.github.com/repos/dimitri/pgloader/issues/141/comments","events_url":"https://api.github.com/repos/dimitri/pgloader/issues/141/events","html_url":"https://github.com/dimitri/pgloader/issues/141","id":52451413,"number":141,"title":"Foreign key clauses (RESTRICT, CASCADE, etc) are not migrated from MySQL to Postgres","user":{"login":"mtyson01","id":7801033,"avatar_url":"https://avatars.githubusercontent.com/u/7801033?v=3","gravatar_id":"","url":"https://api.github.com/users/mtyson01","html_url":"https://github.com/mtyson01","followers_url":"https://api.github.com/users/mtyson01/followers","following_url":"https://api.github.com/users/mtyson01/following{/other_user}","gists_url":"https://api.github.com/users/mtyson01/gists{/gist_id}","starred_url":"https://api.github.com/users/mtyson01/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mtyson01/subscriptions","organizations_url":"https://api.github.com/users/mtyson01/orgs","repos_url":"https://api.github.com/users/mtyson01/repos","events_url":"https://api.github.com/users/mtyson01/events{/privacy}","received_events_url":"https://api.github.com/users/mtyson01/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dimitri/pgloader/labels/How%20To...%20Question","name":"How To... Question","color":"bfe5bf"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2014-12-19T06:15:45Z","updated_at":"2016-02-05T12:58:15Z","closed_at":"2015-01-14T17:35:51Z","body":"So when migrating a database from MySQL to Postgres I noticed that while foreign keys are being migrated, it looks like just a plain default key is created.  Any clauses such as 'ON DELETE CASCADE' are not migrated.\r\n\r\nThe following query demonstrates how to find the FK rules from the MySQL information_schema table.\r\n\r\n```sql\r\n    SELECT rc.table_name,rc.referenced_table_name, constraint_name,\r\n        delete_rule, update_rule,\r\n        GROUP_CONCAT(kcu.column_name SEPARATOR ', ') AS key_cols       \r\n    FROM information_schema.referential_constraints rc\r\n        JOIN information_schema.key_column_usage kcu\r\n        USING(constraint_catalog, constraint_schema, constraint_name)\r\n    WHERE rc.constraint_schema = 'database-name'\r\n        AND rc.table_name = 'table-name'\r\n    GROUP BY rc.constraint_catalog, rc.constraint_schema, rc.constraint_name\r\n```\r\n\r\nI've noticed that  the list-all-fkeys function in mysql-schema.lisp doesn't query the referential_constraints, so I'm guessing that pgloader doesn't attempt to fetch this information from MySQL?"},"comment":{"url":"https://api.github.com/repos/dimitri/pgloader/issues/comments/180344922","html_url":"https://github.com/dimitri/pgloader/issues/141#issuecomment-180344922","issue_url":"https://api.github.com/repos/dimitri/pgloader/issues/141","id":180344922,"user":{"login":"dimitri","id":102900,"avatar_url":"https://avatars.githubusercontent.com/u/102900?v=3","gravatar_id":"","url":"https://api.github.com/users/dimitri","html_url":"https://github.com/dimitri","followers_url":"https://api.github.com/users/dimitri/followers","following_url":"https://api.github.com/users/dimitri/following{/other_user}","gists_url":"https://api.github.com/users/dimitri/gists{/gist_id}","starred_url":"https://api.github.com/users/dimitri/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dimitri/subscriptions","organizations_url":"https://api.github.com/users/dimitri/orgs","repos_url":"https://api.github.com/users/dimitri/repos","events_url":"https://api.github.com/users/dimitri/events{/privacy}","received_events_url":"https://api.github.com/users/dimitri/received_events","type":"User","site_admin":false},"created_at":"2016-02-05T12:58:15Z","updated_at":"2016-02-05T12:58:15Z","body":"I guess the user provided `CAST` is shadowing the default ones. Could you give me an easy to reproduce example so that I see about fixing it?"}}