-- Add migration script here
DROP TABLE beacon_command_invocation;
DROP TABLE beacon_command;

CREATE TABLE beacon_command (
    command_id integer PRIMARY KEY AUTOINCREMENT NOT NULL,

    cmd_parameters varchar NOT NULL
);

CREATE TABLE beacon_command_invocation (
    beacon_id varchar NOT NULL,
    command_id int NOT NULL,

    issue_date int NOT NULL,

    invoker_id int NOT NULL,

    invocation_date int,
    invocation_result varchar,

    PRIMARY KEY (beacon_id, command_id),

    FOREIGN KEY (command_id) REFERENCES beacon_command,
    FOREIGN KEY (beacon_id) REFERENCES beacon_instance,
    FOREIGN KEY (invoker_id) REFERENCES users
);
