Skip to content

Commit

Permalink
rework to make it work with MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
pxp9 committed Sep 2, 2023
1 parent 67bf9d0 commit fa4f135
Show file tree
Hide file tree
Showing 22 changed files with 1,062 additions and 387 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@

-- docker exec -ti mysql mysql -u root -pfang -P 3360 fang -e "$(catn fang/mysql_migrations/migrations/2023-08-17-102017_create_fang_tasks/up.sql)"

/*
why `metadata` and `error_message` are not a TEXT ?
MySQL TEXT type, I think it is stored as a BLOB.
So that breaks FromRow trait, implemented in lib.rs line 183
*/

CREATE TABLE fang_tasks (
id VARCHAR(36) DEFAULT (uuid()) PRIMARY KEY,
metadata JSON NOT NULL,
error_message TEXT,
metadata VARCHAR(2048) NOT NULL,
error_message VARCHAR(2048),
state ENUM('new', 'in_progress', 'failed', 'finished', 'retried') NOT NULL DEFAULT 'new',
task_type VARCHAR(255) NOT NULL DEFAULT 'common', -- TEXT type can not have default value, stupid MySQL policy
uniq_hash CHAR(64),
retries INTEGER NOT NULL DEFAULT 0,
scheduled_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
scheduled_at VARCHAR(32) NOT NULL DEFAULT(CONCAT(CURRENT_TIMESTAMP, '.000000000+00')),
created_at VARCHAR(32) NOT NULL DEFAULT (CONCAT(CURRENT_TIMESTAMP , '.000000000+00')),
updated_at VARCHAR(32) NOT NULL DEFAULT (CONCAT(CURRENT_TIMESTAMP , '.000000000+00'))
);

CREATE INDEX fang_tasks_state_index ON fang_tasks(state);
Expand Down
Loading

0 comments on commit fa4f135

Please sign in to comment.