Skip to content

Missing unique key for constraint (MySQL) #5

@kjsanger

Description

@kjsanger
engine = create_engine(dbconfig.url)
create_database(engine.url) # sqlalchemy_utils
npgmlwarehouse.db.schema.Base.metadata.create_all(engine)
sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (6125, "Failed to add the foreign key constraint. Missing unique key for constraint 'id_iseq_product_ext_digest_fk' in the referenced table ''")
E       [SQL: 
E       CREATE TABLE iseq_external_product_components (
E       	id_iseq_ext_pr_components_tmp BIGINT NOT NULL COMMENT 'Internal to this database id, value can change' AUTO_INCREMENT, 
E       	id_iseq_product_ext CHAR(64) NOT NULL COMMENT 'id (digest) for the external product composition', 
E       	id_iseq_product CHAR(64) NOT NULL COMMENT 'id (digest) for one of the products components', 
E       	num_components TINYINT NOT NULL COMMENT 'Number of component products for this product', 
E       	component_index TINYINT NOT NULL COMMENT 'Unique component index within all components of this product, a value from 1 to the value of num_components column for this product', 
E       	PRIMARY KEY (id_iseq_ext_pr_components_tmp), 
E       	CONSTRAINT id_iseq_product_ext_digest_fk FOREIGN KEY(id_iseq_product_ext) REFERENCES iseq_external_product_metrics (id_iseq_product)
E       )COMMENT='Table linking iseq_external_product_metrics table products to components in the iseq_product_metrics table'
E       

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions