New Zenner
- Join Date:
- Nov 2004
- Posts:
- 69
- Plugin Contributions:
- 0
Importing address_book
I'm moving everything from a very old OSC version to Zen Cart. I've moved all the tables semi-successfully but I've had no luck with the address_book table. I'm no mySQL expert, but I'm pretty sure it's because of the way the primary key is different on both. Here's the table structure for the old one:
CREATE TABLE address_book (
customers_id int(11) NOT NULL default '0',
address_book_id int(11) NOT NULL default '1',
entry_gender char(1) NOT NULL default '',
entry_company varchar(32) default NULL,
entry_firstname varchar(32) NOT NULL default '',
entry_lastname varchar(32) NOT NULL default '',
entry_street_address varchar(64) NOT NULL default '',
entry_suburb varchar(32) default NULL,
entry_postcode varchar(10) NOT NULL default '',
entry_city varchar(32) NOT NULL default '',
entry_state varchar(32) default NULL,
entry_country_id int(11) NOT NULL default '0',
entry_zone_id int(11) NOT NULL default '0',
PRIMARY KEY (address_book_id,customers_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
And the new one:
CREATE TABLE address_book (
address_book_id int(11) NOT NULL auto_increment,
customers_id int(11) NOT NULL default '0',
entry_gender char(1) NOT NULL default '',
entry_company varchar(32) default NULL,
entry_firstname varchar(32) NOT NULL default '',
entry_lastname varchar(32) NOT NULL default '',
entry_street_address varchar(64) NOT NULL default '',
entry_suburb varchar(32) default NULL,
entry_postcode varchar(10) NOT NULL default '',
entry_city varchar(32) NOT NULL default '',
entry_state varchar(32) default NULL,
entry_country_id int(11) NOT NULL default '0',
entry_zone_id int(11) NOT NULL default '0',
PRIMARY KEY (address_book_id),
KEY idx_address_book_customers_id_zen (customers_id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
The primary key is different in both and the only way I could get it to import the data without errors is by changing
PRIMARY KEY (address_book_id)
to
PRIMARY KEY (address_book_id,customers_id)
and dropping and re-creating the table. But since I don't know anything about mySQL, I'm not sure how that would affect Zen Cart. And I imagine it would cause some sort of damage.
If I just try importing the data without changing the table, I get "duplicate entry" errors.