analytics/priv/ingest_repo/migrations/20230320094327_create_v2_schemas.exs
Adam 6637751a5e
Implement Numeric IDs migration (#2762)
* Implement Numeric IDs migration

* Fix typo

* Mute credo for now

* Improve configurability and add stop_t

* Adjust to Ch/Chto only

* Fix opts key for dictionary password

* Add regular ecto migration with numeric ids v2 schemas (#2768)

* Add regular ecto migration

* Fix typo

* Update priv/ingest_repo/migrations/20230320094327_create_v2_schemas.exs

Co-authored-by: Vini Brasil <vini@hey.com>

* Implement v2 events/sessions schema modules (#2777)

* Implement v2 events/sessions schema modules

* Clean up session schemas

---------

Co-authored-by: Vini Brasil <vini@hey.com>

* Update moduledocs

---------

Co-authored-by: Vini Brasil <vini@hey.com>
2023-03-23 09:47:41 +01:00

34 lines
1.1 KiB
Elixir

defmodule Plausible.IngestRepo.Migrations.CreateV2Schemas do
@moduledoc """
Normally, for live environments the migration will be done via
`DataMigration.NumericIDs` module (TBD). In which case PASS_V2_SCHEMA_MIGRATION
environment variable needs to be set, to only make the standard migrate
command write an entry into schema_migrations.
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
if System.get_env("PASS_V2_SCHEMA_MIGRATION") do
:ok
else
execute unwrap("create-events-v2", table_settings: @settings, cluster?: @cluster?)
execute unwrap("create-sessions-v2", table_settings: @settings, cluster?: @cluster?)
end
end
def down do
execute unwrap("drop-events-v2", cluster?: @cluster?)
execute unwrap("drop-sessions-v2", cluster?: @cluster?)
end
end