Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/spider/storage/mysql/mysql_stmt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ std::string const cCreateSchedulerTable = R"(CREATE TABLE IF NOT EXISTS `schedul
std::string const cCreateJobTable = R"(CREATE TABLE IF NOT EXISTS jobs (
`id` BINARY(16) NOT NULL,
`client_id` BINARY(16) NOT NULL,
`creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`state` ENUM('running', 'success', 'cancel', 'fail') NOT NULL DEFAULT 'running',
KEY (`client_id`) USING BTREE,
INDEX idx_jobs_creation_time (`creation_time`),
Expand Down Expand Up @@ -104,15 +104,15 @@ std::string const cCreateTaskDependencyTable = R"(CREATE TABLE IF NOT EXISTS `ta
std::string const cCreateTaskInstanceTable = R"(CREATE TABLE IF NOT EXISTS `task_instances` (
`id` BINARY(16) NOT NULL,
`task_id` BINARY(16) NOT NULL,
`start_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`start_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT `instance_task_id` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
PRIMARY KEY (`id`)
))";

std::string const cCreateSchedulerLeaseTable = R"(CREATE TABLE IF NOT EXISTS `scheduler_leases` (
`scheduler_id` BINARY(16) NOT NULL,
`task_id` BINARY(16) NOT NULL,
`lease_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lease_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT `lease_scheduler_id` FOREIGN KEY (`scheduler_id`) REFERENCES `schedulers` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT `lease_task_id` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
INDEX (`scheduler_id`),
Expand Down
6 changes: 3 additions & 3 deletions tools/scripts/storage/init_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS jobs
(
`id` BINARY(16) NOT NULL,
`client_id` BINARY(16) NOT NULL,
`creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`creation_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`state` ENUM ('running', 'success', 'fail', 'cancel') NOT NULL DEFAULT 'running',
KEY (`client_id`) USING BTREE,
INDEX idx_jobs_creation_time (`creation_time`),
Expand Down Expand Up @@ -103,15 +103,15 @@ CREATE TABLE IF NOT EXISTS `task_instances`
(
`id` BINARY(16) NOT NULL,
`task_id` BINARY(16) NOT NULL,
`start_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`start_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT `instance_task_id` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
PRIMARY KEY (`id`)
);
CREATE TABLE IF NOT EXISTS `scheduler_leases`
(
`scheduler_id` BINARY(16) NOT NULL,
`task_id` BINARY(16) NOT NULL,
`lease_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`lease_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT `lease_scheduler_id` FOREIGN KEY (`scheduler_id`) REFERENCES `schedulers` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
CONSTRAINT `lease_task_id` FOREIGN KEY (`task_id`) REFERENCES `tasks` (`id`) ON UPDATE NO ACTION ON DELETE CASCADE,
INDEX (`scheduler_id`),
Expand Down