-- migrations/02003_rebuild_rule.up.sql
-- Purpose: rebuilding server rule table
-- Author: PPanel Team, 2025-04-21

DROP TABLE IF EXISTS "server_rule_group";
CREATE TABLE "server_rule_group"
(
    "id"         BIGINT GENERATED BY DEFAULT AS IDENTITY NOT NULL,
    "name"       VARCHAR(64)   NOT NULL DEFAULT '',
    "icon"       VARCHAR(255),
    "tags"       TEXT,
    "rules"      TEXT,
    "enable"     BOOLEAN                                                   NOT NULL DEFAULT true,
    "created_at" TIMESTAMP(3),
    "updated_at" TIMESTAMP(3),
    PRIMARY KEY ("id"),
    CONSTRAINT "uni_server_rule_group_name" UNIQUE ("name")
);
CREATE INDEX IF NOT EXISTS "server_rule_group_idx_enable" ON "server_rule_group" ("enable");
