Open source, privacy-first web analytics. Lightweight, cookie-free Google Analytics alternative. Self-hosted or cloud.
TypeScript analyticsanalytics-dashboardclickhouseelixirgoogle-analyticsmarketingopen-source-analyticsphoenixplausible-analyticspostgresqlprivacyprivacy-friendlyself-hostedsimple-analyticsstatisticstailwindcssweb-analyticswebsite-analyticswebsite-statswebsite-tracking
Add table migrations for supporting multiple imports per site (#3785)
Adrian Gruntkowski6915dd5e7848
diff --git a/priv/ingest_repo/migrations/20240123142959_add_import_id_to_imported_tables.exs b/priv/ingest_repo/migrations/20240123142959_add_import_id_to_imported_tables.exsnew file mode 100644index 0000000000..f1a696f6e5--- /dev/null+++ b/priv/ingest_repo/migrations/20240123142959_add_import_id_to_imported_tables.exs@@ -0,0 +1,23 @@+defmodule Plausible.IngestRepo.Migrations.AddImportIdToImportedTables do+ use Ecto.Migration++ @imported_tables [+ :imported_browsers,+ :imported_devices,+ :imported_entry_pages,+ :imported_exit_pages,+ :imported_locations,+ :imported_operating_systems,+ :imported_pages,+ :imported_sources,+ :imported_visitors+ ]++ def change do+ for table <- @imported_tables do+ alter table(table) do+ add(:import_id, :UInt64)+ end+ end+ end+enddiff --git a/priv/repo/migrations/20240123095646_remove_google_analytics_imports_jobs.exs b/priv/repo/migrations/20240123095646_remove_google_analytics_imports_jobs.exsnew file mode 100644index 0000000000..6f5aab7b4d--- /dev/null+++ b/priv/repo/migrations/20240123095646_remove_google_analytics_imports_jobs.exs@@ -0,0 +1,10 @@+defmodule Plausible.Repo.Migrations.RemoveGoogleAnalyticsImportsJobs do+ use Ecto.Migration++ def up do+ execute "DELETE FROM oban_jobs WHERE queue = 'google_analytics_imports'"+ end++ def down do+ end+enddiff --git a/priv/repo/migrations/20240123144308_add_site_imports.exs b/priv/repo/migrations/20240123144308_add_site_imports.exsnew file mode 100644index 0000000000..b3727e43ef--- /dev/null+++ b/priv/repo/migrations/20240123144308_add_site_imports.exs@@ -0,0 +1,20 @@+defmodule Plausible.Repo.Migrations.AddSiteImports do+ use Ecto.Migration++ def change do+ create table(:site_imports) do+ add :start_date, :date, null: false+ add :end_date, :date, null: false+ add :source, :string, null: false+ add :status, :string, null: false++ add :site_id, references(:sites, on_delete: :delete_all), null: false+ add :imported_by_id, references(:users, on_delete: :nilify_all), null: true++ timestamps()+ end++ create index(:site_imports, [:site_id, :start_date])+ create index(:site_imports, [:imported_by_id])+ end+end