analytics/priv/ingest_repo/migrations/20230320094327_create_v2_schemas.exs
hq1 b9c2110472
V2 migration tweaks for self hosted release (#2825)
* Get rid of PASS_V2_SCHEMA_MIGRATION

* Use in-memory domain lookup + regular table settings

* Remove faulty date arithmetic + prev part calculation

* Set V2_MIGRATION_DONE in Mix.env == :dev

* Mute credo
2023-04-13 12:09:39 +02:00

28 lines
833 B
Elixir

defmodule Plausible.IngestRepo.Migrations.CreateV2Schemas do
@moduledoc """
Normally, for live environments the migration will be done via
`DataMigration.NumericIDs` module.
For tests, and entirely new small, self-hosted instances however,
we want to keep the ability of preparing the database without enforcing
any _data_ migration.
"""
use Ecto.Migration
use Plausible.DataMigration, dir: "NumericIDs"
@cluster? false
@settings "SETTINGS index_granularity = 8192"
def up do
execute unwrap("create-events-v2", table_settings: @settings, cluster?: @cluster?)
execute unwrap("create-sessions-v2", table_settings: @settings, cluster?: @cluster?)
end
def down do
execute unwrap("drop-events-v2", cluster?: @cluster?)
execute unwrap("drop-sessions-v2", cluster?: @cluster?)
end
end