-- Deploy gaia:create_table_api_topicrankingscore to mysql

BEGIN;

-- XXX Add DDLs here.
CREATE TABLE `api_topicrankingscore` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `reply_score` double precision NOT NULL,
    `vote_score` double precision NOT NULL,
    `topic_id` integer NOT NULL UNIQUE,
    `last_modified` datetime(6) NOT NULL
);

ALTER TABLE `api_topicrankingscore` ADD CONSTRAINT `fk_topic_id` FOREIGN KEY (`topic_id`) REFERENCES `api_problem` (`id`);

COMMIT;
