MySQL Error:
1060
What does this error mean?
MySQL raises error 1060 when a CREATE TABLE or ALTER TABLE statement attempts to add a column whose name already exists in the target table. In data-pipeline contexts this typically surfaces during schema migrations executed by dbt, Flyway, or raw SQL scripts embedded in ADF or Airflow tasks. The symptom is immediate: the DDL statement fails, the pipeline activity errors out, and any downstream models or transformations that depend on the altered table are skipped or marked failed. Engineers usually encounter this after re-running a migration that was already applied, or when two branches independently add the same column and both get merged. The error is deterministic — retrying the same statement will always fail until the duplicate reference is removed or the migration is made idempotent.
Common causes
- 1A non-idempotent ALTER TABLE ADD COLUMN migration is executed twice — common when CI/CD pipelines retry failed jobs without checking which DDL statements already succeeded.
- 2A CREATE TABLE statement contains the same column name listed more than once, often caused by copy-paste errors or poorly merged SQL files from parallel feature branches.
- 3ORM or code-generation tools (SQLAlchemy autogenerate, Django makemigrations) produce duplicate column definitions when model changes are created independently on two branches and then merged.
- 4A dbt model uses a SELECT * join across two tables that share a column name, and the result is materialized into a new table — the duplicate column name triggers 1060 during CREATE TABLE AS SELECT.
- 5Manual hotfix scripts are run against production without checking migration state, re-adding a column that was already applied by the regular migration pipeline.
How to fix it
- 1Step 1: Confirm which column is duplicated. Read the full error message — it includes the column name: `ERROR 1060 (42S21): Duplicate column name 'status'`. Note the exact name.
- 2Step 2: Check if the column already exists in the table: `SELECT column_name, data_type, ordinal_position FROM information_schema.columns WHERE table_schema = 'your_db' AND table_name = 'your_table' AND column_name = 'status';`
- 3Step 3: If the column exists and your migration tried to add it, make the migration idempotent. Wrap the ALTER in a stored procedure: `DELIMITER // CREATE PROCEDURE add_col_if_missing() BEGIN IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_schema='your_db' AND table_name='your_table' AND column_name='status') THEN ALTER TABLE your_table ADD COLUMN status VARCHAR(50); END IF; END // DELIMITER ; CALL add_col_if_missing(); DROP PROCEDURE add_col_if_missing;`
- 4Step 4: If the error comes from a CREATE TABLE with duplicate column names, inspect the DDL: `SHOW CREATE TABLE your_table;` or search your migration file for the duplicated column name. Remove the duplicate definition.
- 5Step 5: If the error originates from a SELECT * join in dbt or a CTAS statement, explicitly list columns instead of using SELECT *. Alias the duplicate: `SELECT a.status AS source_status, b.status AS target_status FROM table_a a JOIN table_b b ON a.id = b.id;`
- 6Step 6: Mark the migration as applied in your migration tool if you confirmed the column already exists. For Flyway: `flyway repair` to fix the schema history table. For Liquibase: insert a row into DATABASECHANGELOG manually.
- 7Step 7: Re-run the pipeline. In ADF: rerun the failed activity from the pipeline monitor. In Airflow: clear the failed task instance. Verify the downstream models complete successfully.
Example log output
2026-05-11 08:14:32 ERROR 1060 (42S21) at line 14: Duplicate column name 'last_modified'
mysql> ALTER TABLE pipeline_runs ADD COLUMN last_modified DATETIME DEFAULT CURRENT_TIMESTAMP;
ERROR 1060 (42S21): Duplicate column name 'last_modified'