CREATE TABLE drweb_contract_agent_$mid (
  id int(11) NOT NULL AUTO_INCREMENT,
  cid int(11) NOT NULL,
  agent_uuid varchar(50) NOT NULL,
  description varchar(100) NOT NULL,
  url varchar(255) NOT NULL,
  tariff_id int(11) NOT NULL,
  status int(11) DEFAULT NULL,
  new_agent int(11) DEFAULT NULL,
  PRIMARY KEY (id)
);
CREATE TABLE drweb_contract_agent_status_$mid (
  id int(11) NOT NULL AUTO_INCREMENT,
  agent_id int(11) NOT NULL,
  date_from date DEFAULT NULL,
  date_to date DEFAULT NULL,
  status int(11) NOT NULL,
  tariff_id int(11) DEFAULT NULL,
  KEY id (id)
);
CREATE TABLE drweb_contract_agent_status_log_$mid (
  id int(11) NOT NULL AUTO_INCREMENT,
  date date DEFAULT NULL,
  agent_id int(11) NOT NULL,
  date_from date DEFAULT NULL,
  date_to date DEFAULT NULL,
  status int(11) NOT NULL,
  tariff_id int(11) DEFAULT NULL,
  user_id int(11) DEFAULT NULL,
  KEY id (id)
);
CREATE TABLE drweb_tariffs_$mid (
  id int(11) NOT NULL AUTO_INCREMENT,
  group_title varchar(150) NOT NULL,
  sid int(11) NOT NULL,
  title varchar(255) NOT NULL,
  date_from_view date DEFAULT NULL,
  date_to_view date DEFAULT NULL,
  date_from_work date DEFAULT NULL,
  date_to_work date DEFAULT NULL,
  next_tariff int(11) DEFAULT NULL,
  group_for_view varchar(255) DEFAULT NULL,
  only_for_new varchar(25) NOT NULL,
  sid_new int(11) NOT NULL,
  PRIMARY KEY (`id`)
);

ALTER TABLE drweb_contract_agent_$mid DROP COLUMN url;
ALTER TABLE drweb_contract_agent_$mid ADD COLUMN status_date DATETIME NULL DEFAULT NULL AFTER status;
ALTER TABLE drweb_contract_agent_$mid ADD COLUMN date_from DATETIME NULL DEFAULT NULL AFTER status_date,DROP COLUMN new_agent;

ALTER TABLE drweb_contract_agent_status _$mid DROP COLUMN url;
ALTER TABLE drweb_contract_agent_status_$mid  CHANGE COLUMN date dt DATETIME NULL DEFAULT NULL AFTER id;
ALTER TABLE drweb_contract_agent_status_$mid  CHANGE COLUMN date date DATETIME NULL DEFAULT NULL AFTER agent_id;


 






