title: changing data type from bigint to tinyint form existing table with foreign key reference
body: <p>I have to optimize my database which has 212 tables. One table primary key is acting as foreign key for 94 tables. For example I have this table:</p>
  
  <pre><code>create table CUSTOMER (
      CUSTOMER_ID BIGINT NOT NULL,
      CUSTOMER_NAME VARCHAR(255) NOT NULL UNIQUE,
      CONTACT_PERSON VARCHAR(255) NOT NULL,
      CUSTOMER_EMAIL VARCHAR(255) NOT NULL,
      ADDRESS VARCHAR(255),
      CITY VARCHAR(255),
      PHONE VARCHAR(255),
      FAX VARCHAR(255),
  
      constraint CUSTOMER_PK PRIMARY KEY (CUSTOMER_ID)
  );
  </code></pre>
  
  <p>Here <code>CUSTOMER_ID</code> is acting as a reference that is a foreign key for 94 tables. Here is one table as an example:</p>
  
  <pre><code>create table CUSTOMER_STATUS (
      CUSTOMER_DETAILS_ID BIGINT NOT NULL,
      CUSTOMER_ID BIGINT NOT NULL,
      USER_ID BIGINT NOT NULL,
      TRIAL_PERIOD BIGINT NOT NULL,
      TRIAL_PERIOD_TYPE BIGINT NOT NULL,
      EXPIRY_DATE BIGINT NOT NULL,
      MAXIMUM_CLIENTS BIGINT NOT NULL,
      STATUS BIGINT NOT NULL,
      AUTO_AUTHORIZATION BIGINT NOT NULL,
  
      constraint CUSTOMER_STATUS_PK PRIMARY KEY (CUSTOMER_ID,CUSTOMER_DETAILS_ID),
      constraint CUSTOMER_STATUS_FK1 FOREIGN KEY (CUSTOMER_ID) references CUSTOMER(CUSTOMER_ID)
  );
  </code></pre>
  
  <p>I need to change <code>CUSTOMER_ID</code> data type from <code>BIGINT</code> to <code>TINYINT</code> for all tables, but I'm getting an error because of foreign key constraints.</p>
  
  <p>Error: </p>
  
  <pre><code>mysql&gt; alter table CUSTOMER MODIFY CUSTOMER_ID TINYINT;
      ERROR 1025 (HY000): Error on rename of '.\uds7\#sql-670_cdd' to '.\uds7\customer' (errno: 150)
  </code></pre>
  
  <p>What should I do to make changes without affecting my table data? </p>