-- Deploy gaia:hippo_2018_01_10_add_userbrowsing to mysql

BEGIN;

-- XXX Add DDLs here.

CREATE TABLE `hippo_user_browsing` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `user_id` integer NOT NULL,
    `last_browsing_time` datetime(6) NOT NULL,
    `merchant_id` bigint NOT NULL
)
;
ALTER TABLE `hippo_user_browsing` ADD CONSTRAINT `user_id_refs_id_ace02e36` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
ALTER TABLE `hippo_user_browsing` ADD CONSTRAINT `merchant_id_refs_id_4398ae22` FOREIGN KEY (`merchant_id`) REFERENCES `hippo_merchant` (`id`);
CREATE TABLE `hippo_user_browsing_detail` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `userbrowsing_id` integer NOT NULL,
    `user_id` integer NOT NULL,
    `page_type` integer NOT NULL,
    `browsing_time` datetime(6) NOT NULL,
    `info_id` varchar(50)
)
;
ALTER TABLE `hippo_user_browsing_detail` ADD CONSTRAINT `user_id_refs_id_6840d473` FOREIGN KEY (`user_id`) REFERENCES `auth_user` (`id`);
ALTER TABLE `hippo_user_browsing_detail` ADD CONSTRAINT `userbrowsing_id_refs_id_237a22f0` FOREIGN KEY (`userbrowsing_id`) REFERENCES `hippo_user_browsing` (`id`);


COMMIT;
