-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add orcahello_id to feeds, update deps (#596)
* Update dependencies * Add orcahello_id to feeds with index
- Loading branch information
Showing
7 changed files
with
440 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
54 changes: 54 additions & 0 deletions
54
server/priv/repo/migrations/20240820200730_install_ash-functions_extension_4.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
25 changes: 25 additions & 0 deletions
25
server/priv/repo/migrations/20240820200920_add_orcahello_id_to_feeds.exs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
] | ||
} |
Oops, something went wrong.