-- +goose Up
-- create routes table
CREATE TABLE IF NOT EXISTS b2b_routes (
  id          INT AUTO_INCREMENT PRIMARY KEY,
  name        VARCHAR(255) NOT NULL UNIQUE,
  path        VARCHAR(255) NULL,
  component   VARCHAR(255) NOT NULL COMMENT 'path to component file',
  layout      VARCHAR(50) DEFAULT 'default' COMMENT "'default' | 'empty'",
  meta        JSON DEFAULT '{}',
  is_active   BOOLEAN DEFAULT TRUE,
  sort_order  INT DEFAULT 0,
  parent_id   INT NULL,

  CONSTRAINT fk_parent
    FOREIGN KEY (parent_id)
    REFERENCES b2b_routes(id)
    ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT IGNORE INTO b2b_routes
  (name, path, component, layout, meta, is_active, sort_order, parent_id)
VALUES
  ('root', '', '', 'default', '{"trans": "route.root"}', 0, 0, 0),
  ('home', '', '@/views/HomeView.vue', 'default', '{"trans": "route.home"}', 1, 0, 0),
  ('login', 'login', '@/views/LoginView.vue', 'empty', '{"guest":true}', 1, 2, NULL),
  ('register', 'register', '@/views/RegisterView.vue', 'empty', '{"guest":true}', 1, 3, NULL),
  ('password-recovery', 'password-recovery', '@/views/PasswordRecoveryView.vue', 'empty', '{"guest":true}', 1, 4, NULL),
  ('reset-password', 'reset-password', '@/views/ResetPasswordView.vue', 'empty', '{"guest":true}', 1, 5, NULL),
  ('verify-email', 'verify-email', '@/views/VerifyEmailView.vue', 'empty', '{"guest":true}', 1, 6, NULL);

-- +goose Down

DROP TABLE IF EXISTS b2b_routes;

