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