Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populate site_imports from sites.imported_data in CE #4155

Merged
merged 7 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions lib/plausible/data_migration/site_imports.ex
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
defmodule Plausible.DataMigration.SiteImports do

Check failure on line 1 in lib/plausible/data_migration/site_imports.ex

View workflow job for this annotation

GitHub Actions / App code does not change at the same time

Code and migrations shouldn't be changed at the same time
@moduledoc """
!!!WARNING!!!: This script is used in migrations. Please take special care
when altering it.

Site imports migration backfilling SiteImport entries for old imports
and alters import end dates to match actual end date of respective import stats.


"""

import Ecto.Query
Expand Down
7 changes: 6 additions & 1 deletion lib/plausible/data_migration/versioned_sessions.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
defmodule Plausible.DataMigration.VersionedSessions do
@moduledoc """
Sessions CollapsingMergeTree -> VersionedCollapsingMergeTree migration, SQL files available at:
!!!WARNING!!!: This script is used in migrations. Please take special care
when altering it.

Sessions CollapsingMergeTree -> VersionedCollapsingMergeTree migration,
SQL files available at:

priv/data_migrations/VersionedSessions/sql
"""
use Plausible.DataMigration, dir: "VersionedSessions", repo: Plausible.IngestRepo
Expand Down
14 changes: 14 additions & 0 deletions priv/repo/migrations/20240528115149_migrate_site_imports.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
defmodule Plausible.Repo.Migrations.MigrateSiteImports do
use Plausible
use Ecto.Migration

def up do
if ce?() do
Plausible.DataMigration.SiteImports.run(dry_run?: false)
end
end

def down do
raise "Irreversible"
end
end
14 changes: 8 additions & 6 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ seeded_token = Plausible.Plugins.API.Token.generate("seed-token")
{:ok, _goal5} = Plausible.Goals.create(site, %{"page_path" => Enum.random(long_random_paths)})
{:ok, outbound} = Plausible.Goals.create(site, %{"event_name" => "Outbound Link: Click"})

{:ok, _funnel} =
Plausible.Funnels.create(site, "From homepage to login", [
%{"goal_id" => goal1.id},
%{"goal_id" => goal2.id},
%{"goal_id" => goal3.id}
])
if Plausible.ee?() do
{:ok, _funnel} =
Plausible.Funnels.create(site, "From homepage to login", [
%{"goal_id" => goal1.id},
%{"goal_id" => goal2.id},
%{"goal_id" => goal3.id}
])
end

put_random_time = fn
date, 0 ->
Expand Down
Loading