jim256 / ebay

0 stars 0 forks source link

mysql - Setup instance and table per schema #3

Closed james-carpenter closed 4 years ago

james-carpenter commented 4 years ago
CREATE TABLE autosearch.cars_ebay_test (
  id INT(11) NOT NULL AUTO_INCREMENT,
  name VARCHAR(256) DEFAULT NULL,
  source VARCHAR(64) DEFAULT NULL,
  price INT(11) DEFAULT NULL,
  year INT(11) DEFAULT NULL,
  make VARCHAR(64) DEFAULT NULL,
  model VARCHAR(64) DEFAULT NULL,
  mileage INT(11) DEFAULT NULL,
  transmission VARCHAR(64) DEFAULT NULL,
  num_cylinders INT(11) DEFAULT NULL,
  drive_type VARCHAR(64) DEFAULT NULL,
  body_type VARCHAR(64) DEFAULT NULL,
  fuel_type VARCHAR(64) DEFAULT,
  title_type VARCHAR(64) DEFAULT NULL,
  vin VARCHAR(64) DEFAULT NULL,
  trim TEXT DEFAULT NULL,
  color VARCHAR(256) DEFAULT NULL,
  city VARCHAR(256) DEFAULT NULL,
  state VARCHAR(256) DEFAULT NULL,
  country VARCHAR(256) DEFAULT NULL,
  source_id BIGINT(20) DEFAULT NULL,
  url VARCHAR(512) DEFAULT NULL,
  date_listed DATETIME DEFAULT NULL,
  date_found DATETIME DEFAULT NULL,
  date_updated DATETIME DEFAULT NULL,
  num_doors INT(11) DEFAULT NULL,
  date_analyzed DATETIME DEFAULT NULL,
  seller_type VARCHAR(15) DEFAULT NULL,
  details LONGTEXT DEFAULT NULL,
  page_views INT(11) DEFAULT NULL,
  favorited INT(11) DEFAULT NULL,
  PRIMARY KEY (id)
)
james-carpenter commented 4 years ago
create index source__source_id_idx on cars_ebay_test(source, source_id);
alter table cars_ebay_test add constraint source__source_id_uniq unique (source, source_id);