Skip to content

Commit

Permalink
Merge pull request #21 from Recruitee/change-campaign-id-and-product-…
Browse files Browse the repository at this point in the history
…id-field-types

Change campaign_id and product_id field types
  • Loading branch information
rdk08 authored Dec 1, 2022
2 parents e060cb9 + 6d60b56 commit 22af8e5
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/plausible/event/clickhouse_schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ defmodule Plausible.ClickhouseEvent do
field :site_id, :integer
field :page_id, :integer
field :job_id, :integer
field :campaign_id, :integer
field :product_id, :integer
field :timestamp, :naive_datetime

field :referrer, :string, default: ""
Expand All @@ -26,6 +24,8 @@ defmodule Plausible.ClickhouseEvent do
field :utm_campaign, :string, default: ""
field :utm_content, :string, default: ""
field :utm_term, :string, default: ""
field :campaign_id, :string, default: ""
field :product_id, :string, default: ""

field :country_code, :string, default: ""
field :subdivision1_code, :string, default: ""
Expand Down
4 changes: 2 additions & 2 deletions lib/plausible/session/clickhouse_schema.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ defmodule Plausible.ClickhouseSession do
field :session_id, :integer
field :company_id, :integer
field :site_id, :integer
field :campaign_id, :integer
field :product_id, :integer

field :start, :naive_datetime
field :duration, :integer
Expand All @@ -29,6 +27,8 @@ defmodule Plausible.ClickhouseSession do
field :utm_term, :string
field :referrer, :string
field :referrer_source, :string
field :campaign_id, :string
field :product_id, :string

field :country_code, :string, default: ""
field :subdivision1_code, :string, default: ""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Plausible.ClickhouseRepo.Migrations.RemoveCampaignId do
use Ecto.Migration

def change do
alter table(:events) do
remove :campaign_id
end

alter table(:sessions) do
remove :campaign_id
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
defmodule Plausible.ClickhouseRepo.Migrations.RemoveProductId do
use Ecto.Migration

def change do
alter table(:events) do
remove :product_id
end

alter table(:sessions) do
remove :product_id
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule Plausible.ClickhouseRepo.Migrations.RecreateCampaignIdAndProductId do
use Ecto.Migration

def change do
alter table(:events) do
add(:campaign_id, :string)
add(:product_id, :string)
end

alter table(:sessions) do
add(:campaign_id, :string)
add(:product_id, :string)
end
end
end

0 comments on commit 22af8e5

Please sign in to comment.