Skip to content

Commit

Permalink
Add orcahello_id to feeds, update deps (#596)
Browse files Browse the repository at this point in the history
* Update dependencies

* Add orcahello_id to feeds with index
  • Loading branch information
skanderm committed Aug 20, 2024
1 parent df28b0b commit 5cc30c8
Show file tree
Hide file tree
Showing 7 changed files with 440 additions and 38 deletions.
2 changes: 2 additions & 0 deletions server/lib/orcasite/radio/feed.ex
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ defmodule Orcasite.Radio.Feed do
index [:visible]
index [:slug]
index [:dataplicity_id]
index [:orcahello_id]
end

migration_defaults id: "fragment(\"uuid_generate_v7()\")"
Expand All @@ -38,6 +39,7 @@ defmodule Orcasite.Radio.Feed do
attribute :bucket_region, :string, public?: true
attribute :cloudfront_url, :string, public?: true
attribute :dataplicity_id, :string, public?: true
attribute :orcahello_id, :string, public?: true

create_timestamp :inserted_at
update_timestamp :updated_at
Expand Down
6 changes: 3 additions & 3 deletions server/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ defmodule Orcasite.Mixfile do
{:corsica, "~> 2.1"},
{:telemetry_metrics, "~> 1.0"},
{:telemetry_poller, "~> 1.0"},
{:ash, "~> 3.0.16"},
{:ash, "~> 3.4.1"},
{:ash_admin, "~> 0.11.3"},
{:ash_postgres, "~> 2.0"},
{:ash_postgres, "~> 2.2"},
{:picosat_elixir, "~> 0.2.3"},
{:heroicons, "~> 0.5"},
{:oban, "~> 2.14"},
Expand All @@ -88,7 +88,7 @@ defmodule Orcasite.Mixfile do
{:syn, "~> 3.3"},
{:mjml, "~> 3.0.1"},
{:zappa, github: "skanderm/zappa", branch: "master"},
{:ash_uuid, github: "skanderm/ash_uuid", tag: "319e6d6"},
{:ash_uuid, github: "skanderm/ash_uuid", tag: "5140d0"},
# {:ash_uuid, "~> 1.1.1"},
{:ash_graphql, github: "ash-project/ash_graphql", branch: "main"},
{:ash_json_api, "~> 1.2"},
Expand Down
70 changes: 37 additions & 33 deletions server/mix.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
defmodule Orcasite.Repo.Migrations.InstallAshFunctionsExtension420240820200728 do
@moduledoc """
Installs any extensions that are mentioned in the repo's `installed_extensions/0` callback
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""

use Ecto.Migration

def up do
execute("""
CREATE OR REPLACE FUNCTION uuid_generate_v7()
RETURNS UUID
AS $$
DECLARE
timestamp TIMESTAMPTZ;
microseconds INT;
BEGIN
timestamp = clock_timestamp();
microseconds = (cast(extract(microseconds FROM timestamp)::INT - (floor(extract(milliseconds FROM timestamp))::INT * 1000) AS DOUBLE PRECISION) * 4.096)::INT;
RETURN encode(
set_byte(
set_byte(
overlay(uuid_send(gen_random_uuid()) placing substring(int8send(floor(extract(epoch FROM timestamp) * 1000)::BIGINT) FROM 3) FROM 1 FOR 6
),
6, (b'0111' || (microseconds >> 8)::bit(4))::bit(8)::int
),
7, microseconds::bit(8)::int
),
'hex')::UUID;
END
$$
LANGUAGE PLPGSQL
VOLATILE;
""")

execute("""
CREATE OR REPLACE FUNCTION timestamp_from_uuid_v7(_uuid uuid)
RETURNS TIMESTAMP WITHOUT TIME ZONE
AS $$
SELECT to_timestamp(('x0000' || substr(_uuid::TEXT, 1, 8) || substr(_uuid::TEXT, 10, 4))::BIT(64)::BIGINT::NUMERIC / 1000);
$$
LANGUAGE SQL
IMMUTABLE PARALLEL SAFE STRICT;
""")
end

def down do
# Uncomment this if you actually want to uninstall the extensions
# when this migration is rolled back:
execute("DROP FUNCTION IF EXISTS uuid_generate_v7(), timestamp_from_uuid_v7(uuid)")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
defmodule Orcasite.Repo.Migrations.AddOrcahelloIdToFeeds do
@moduledoc """
Updates resources based on their most recent snapshots.
This file was autogenerated with `mix ash_postgres.generate_migrations`
"""

use Ecto.Migration

def up do
alter table(:feeds) do
add :orcahello_id, :text
end

create index(:feeds, [:orcahello_id])
end

def down do
drop_if_exists index(:feeds, [:orcahello_id])

alter table(:feeds) do
remove :orcahello_id
end
end
end
4 changes: 2 additions & 2 deletions server/priv/resource_snapshots/repo/extensions.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"ash_functions_version": 4,
"installed": [
"citext",
"uuid-ossp",
"postgis",
"ash-uuid_v1",
"pg_stat_statements",
"ash-functions"
],
"ash_functions_version": 3
]
}
Loading

0 comments on commit 5cc30c8

Please sign in to comment.