`#1215 – Cannot add foreign key constraint

In order to make the wp_posts(ID) a REFERENCE for the FOREIGN KEY, you should also set the wp_pageviews.ID‘s attributes as UNSIGNED and keep the same data type for the wp_pageviews.ID as (bigint) .

Let me know if this helps you.