Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

1.0 KB
Raw Blame
const { queriesRunner, dbName } = require('./setup')

const queries = [
  // Add CAPTCHA fields to project table
  `ALTER TABLE ${dbName}.project ADD COLUMN IF NOT EXISTS isCaptchaProject Int8 DEFAULT 0;`,
  `ALTER TABLE ${dbName}.project ADD COLUMN IF NOT EXISTS captchaSecretKey Nullable(String) CODEC(ZSTD(3));`,
  `ALTER TABLE ${dbName}.project ADD COLUMN IF NOT EXISTS captchaDifficulty UInt8 DEFAULT 4;`,
  `ALTER TABLE ${dbName}.project ADD COLUMN IF NOT EXISTS captchaDifficultyMode String DEFAULT 'manual' CODEC(ZSTD(3));`,

  // Create CAPTCHA analytics table (same structure as in initialise_database.js)
  `CREATE TABLE IF NOT EXISTS ${dbName}.captcha
  (
    pid FixedString(12),
    dv LowCardinality(Nullable(String)),
    br LowCardinality(Nullable(String)),
    os Nullable(String) CODEC(ZSTD(3)),
    cc Nullable(FixedString(2)),
    manuallyPassed UInt8,
    created DateTime('UTC') CODEC(Delta(4), LZ4)
  )
  ENGINE = MergeTree()
  PARTITION BY toYYYYMM(created)
  ORDER BY (pid, created);`,
]

queriesRunner(queries)