mirror of
https://github.com/plausible/analytics.git
synced 2024-12-23 09:33:19 +03:00
Saved segments/create table (#4797)
* Add migration for Saved Segments * Remove premature optimisation * Format * Refactor to explicit segment type
This commit is contained in:
parent
d620432227
commit
b22b35793c
22
priv/repo/migrations/20241107120000_create_segments.exs
Normal file
22
priv/repo/migrations/20241107120000_create_segments.exs
Normal file
@ -0,0 +1,22 @@
|
||||
defmodule Plausible.Repo.Migrations.CreateSegments do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
execute(
|
||||
"CREATE TYPE segment_type AS ENUM ('personal', 'site')",
|
||||
"DROP TYPE segment_type"
|
||||
)
|
||||
|
||||
create table(:segments) do
|
||||
add :name, :string, null: false
|
||||
add :type, :segment_type, null: false, default: "personal"
|
||||
add :segment_data, :map, null: false
|
||||
add :site_id, references(:sites, on_delete: :delete_all), null: false
|
||||
add :owner_id, references(:users, on_delete: :nothing), null: true
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
create index(:segments, [:site_id])
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user