-- migrate:up
DROP TABLE IF EXISTS "server";

-- migrate:down
CREATE TABLE IF NOT EXISTS "server"
(
    "id"               BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
    "name"             varchar(100)   NOT NULL DEFAULT '',
    "tags"             varchar(128)   NOT NULL DEFAULT '',
    "country"          varchar(128)   NOT NULL DEFAULT '',
    "city"             varchar(128)   NOT NULL DEFAULT '',
    "latitude"         varchar(128)   NOT NULL DEFAULT '',
    "longitude"        varchar(128)   NOT NULL DEFAULT '',
    "server_addr"      varchar(100)   NOT NULL DEFAULT '',
    "relay_mode"       varchar(20)    NOT NULL DEFAULT 'none',
    "relay_node"       text,
    "speed_limit"      bigint                                                        NOT NULL DEFAULT '0',
    "traffic_ratio"    decimal(4, 2)                                                 NOT NULL DEFAULT '0.00',
    "group_id"         bigint                                                                 DEFAULT NULL,
    "protocol"         varchar(20)    NOT NULL DEFAULT '',
    "config"           text,
    "enable"           SMALLINT                                                    NOT NULL DEFAULT '1',
    "sort"             bigint                                                        NOT NULL DEFAULT '0',
    "last_reported_at" TIMESTAMP(3)                                                            DEFAULT NULL,
    "created_at"       TIMESTAMP(3)                                                            DEFAULT NULL,
    "updated_at"       TIMESTAMP(3)                                                            DEFAULT NULL,
    PRIMARY KEY ("id")
);
CREATE INDEX IF NOT EXISTS "server_idx_group_id" ON "server" ("group_id");

