improvement!: change defaults for uuids to gen_random_uuid()

This commit is contained in:
Zach Daniel 2024-03-27 17:20:07 -04:00
parent c436973e9f
commit 804482b8ac
35 changed files with 3104 additions and 3 deletions

View file

@ -0,0 +1,17 @@
# Upgrade from 2.0 to 3.0
There are only three breaking changes in this release, one of them is very significant, the other two are minor.
# AshPostgres officially supports only postgresql version 14 or higher
While _most_ things will work with versions as low as 11, we are relying on features of newer postgres versions. We will not be testing against versions lower than 14, and we will not be supporting them. If you are using an older version of postgres, you will need to upgrade.
If you _must_ use an older version, the only thing that you'll need to change in the short term is to handle the fact that we now use `gen_random_uuid()` as the default for generated uuids (see below), which is only available after postgres _13_. Additionally, if you are on postgres 12 or earlier, you will need to replace `ANYCOMPATIBLE` with `ANYELEMENT` in the `ash-functions` extension migration.
## `gen_random_uuid()` is now the default for generated uuids
In the past, we used `uuid_generate_v4()` as the default for generated uuids. This function is part of the `uuid-ossp` extension, which is not installed by default in postgres. `gen_random_uuid()` is a built-in function that is available in all versions of postgres 13 and higher. If you are using an older version of postgres, you will need to install the `uuid-ossp` extension and change the default in your migrations.
## utc datetimes that default to `&DateTime.now/0` are now cast to `UTC`
This is a layer of safety to ensure consistency in the default values of a database and the datetimes that are sent to/from the database. When you generate migrations you will notice your timestamps change from defaulting to `now()` in your migrations to `now() AT TIMESTAMP 'utc'`. You are free to undo this change, by setting `migration_defaults` in your resource, or simply by deleting the generated migration.

View file

@ -2816,11 +2816,11 @@ defmodule AshPostgres.MigrationGenerator do
@uuid_functions [&Ash.UUID.generate/0, &Ecto.UUID.generate/0]
defp default(%{name: name, default: default}, resource, repo) when is_function(default) do
defp default(%{name: name, default: default}, resource, _repo) when is_function(default) do
configured_default(resource, name) ||
cond do
default in @uuid_functions && "uuid-ossp" in (repo.config()[:installed_extensions] || []) ->
~S[fragment("uuid_generate_v4()")]
default in @uuid_functions ->
~S[fragment("gen_random_uuid()")]
default == (&DateTime.utc_now/0) ->
~S[fragment("(now() AT TIME ZONE 'utc')")]

View file

@ -0,0 +1,67 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "boolean",
"source": "is_active",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "user_id",
"references": {
"name": "accounts_user_id_fkey",
"table": "users",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "accounts",
"hash": "91E32D9EB389743A8F1C9CC024CD8E0CA45EE5DDB37484B324E0ACFA54E89784",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,72 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "first_name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "last_name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "map",
"source": "bio",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"text"
],
"source": "badges",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "authors",
"hash": "DA8EA3017418D8D188C05FEFB74864CEE8B3943341B2A9F2178A322694AF81E7",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,67 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "score",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "resource_id",
"references": {
"name": "comment_ratings_resource_id_fkey",
"table": "comments",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": null,
"deferrable": false,
"destination_attribute_default": "fragment(\"gen_random_uuid()\")",
"destination_attribute_generated": false,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "comment_ratings",
"hash": "F5F7409C3174AEDA4167846E09BF6F8BC65F84BAEAE72398854734449437956A",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,125 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "title",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "likes",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "utc_datetime_usec",
"source": "arbitrary_timestamp",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "post_id",
"references": {
"name": "special_name_fkey",
"table": "posts",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": "delete",
"on_update": "update",
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "author_id",
"references": {
"name": "comments_author_id_fkey",
"table": "authors",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "comments",
"hash": "D1DFF344AC9FD8F71978647814798F08C614BAB6AE07BC8B2BAEBB0FA050F624",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,125 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "title",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "likes",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "utc_datetime_usec",
"source": "arbitrary_timestamp",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "post_id",
"references": {
"name": "special_name_fkey",
"table": "posts",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": "delete",
"on_update": "update",
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "author_id",
"references": {
"name": "comments_author_id_fkey",
"table": "authors",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "comments",
"hash": "44CDB628468EA313E2D70189D0F5F6E6318886DB0F20C5CE6E05D925F92D1342",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,29 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
}
],
"table": "complex_calculations_certifications",
"hash": "EAD1F09DA125BB08FDB1186B925BCD84F0DAD8B7C996318E30B3904A7F96EE8D",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,105 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "user_id",
"references": {
"name": "complex_calculations_certifications_channel_members_user_id_fkey",
"table": "users",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "channel_id",
"references": {
"name": "complex_calculations_certifications_channel_members_channel_id_fkey",
"table": "complex_calculations_channels",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "complex_calculations_certifications_channel_members",
"hash": "FE83A946EF1F2BE71039C4FA23434AD0CF63AB5FF19427353B76FE324C7E7261",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,105 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "user_id",
"references": {
"name": "complex_calculations_certifications_channel_members_user_id_fkey",
"table": "users",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "channel_id",
"references": {
"name": "complex_calculations_certifications_channel_members_channel_id_fkey",
"table": "complex_calculations_channels",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "complex_calculations_certifications_channel_members",
"hash": "AA00163B97E1B6DB621688CDF33EC74878BA28102A5D6B278973F55987B7DB34",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,49 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "complex_calculations_channels",
"hash": "3BEBD2B361ED4CA69120920B131113996BF5530E24952310AB88E49A79906943",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,49 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "complex_calculations_channels",
"hash": "660EEED8929709A3B61F1C8C6804305240DE60664B7BE05639869C7E862AFE6F",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,97 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "status",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "utc_datetime_usec",
"source": "documented_at",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "skill_id",
"references": {
"name": "complex_calculations_documentations_skill_id_fkey",
"table": "complex_calculations_skills",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "complex_calculations_documentations",
"hash": "F38F4D9461F1C7CF89A978E50032F68A69874BC69C37CD1CCCE561B08CA9BEC1",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,97 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "status",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "utc_datetime_usec",
"source": "documented_at",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "skill_id",
"references": {
"name": "complex_calculations_documentations_skill_id_fkey",
"table": "complex_calculations_skills",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "complex_calculations_documentations",
"hash": "A7F66DE054E88AC2C1975380748C45A1584108E616E8F9B1FF66BD694D34CC96",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,67 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "false",
"size": null,
"type": "boolean",
"source": "removed",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "certification_id",
"references": {
"name": "complex_calculations_skills_certification_id_fkey",
"table": "complex_calculations_certifications",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "complex_calculations_skills",
"hash": "94D2C1A987E08BE36ED2CD4CF8EDAE8476E5CCE71BF4EBBBF51F2B42B8F42816",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,59 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "full_name",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "entities",
"hash": "C996CEB931DB10DD0F1FA9FD70A309242B8A8CBC689E39901497AE8B17261DE7",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,59 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "full_name",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "entities",
"hash": "F22199F8D6AFDC5F8565062FA3E939A434105F3AB9415B34800C35157715F147",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,107 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "code",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "must_be_present",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "role",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "organization_id",
"references": {
"name": "managers_organization_id_fkey",
"table": "orgs",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "managers",
"hash": "17D7508E7D328026B42E37C76865A1FA6C2BCBCEEF745358769A19A39C71C61F",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [
{
"name": "uniq_code",
"keys": [
"code"
],
"base_filter": null,
"all_tenants?": false,
"index_name": "managers_uniq_code_index"
}
],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,49 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "multitenant_orgs",
"hash": "8272A81AAF88BCC843DCB78558ECE612D31CD6E3FFB0AEA17A94B0223A4815BB",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": true,
"attribute": "id",
"strategy": "attribute"
},
"schema": null,
"identities": [
{
"name": "unique_by_name",
"keys": [
"name"
],
"base_filter": null,
"all_tenants?": false,
"index_name": "multitenant_orgs_unique_by_name_index"
}
],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,39 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "orgs",
"hash": "964A05962CF0871AF3C96713E799037155149E5E69FAB9A85BD4449F2A075906",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,85 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "post_id",
"references": {
"name": "post_followers_post_id_fkey",
"table": "posts",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "follower_id",
"references": {
"name": "post_followers_follower_id_fkey",
"table": "users",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "post_followers",
"hash": "0996CE6B4B7B42D124DCCE64AAC44D0E41FD5B877F27F38B703FD62BDAC14520",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,67 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "score",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "resource_id",
"references": {
"name": "post_ratings_resource_id_fkey",
"table": "posts",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": null,
"deferrable": false,
"destination_attribute_default": "fragment(\"gen_random_uuid()\")",
"destination_attribute_generated": false,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "post_ratings",
"hash": "251643EE9B79229CEB3A6CEB2CCAEF67E02A5017D780607E6AA87C016F9D5366",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,49 @@
{
"attributes": [
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "time",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "browser",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "post_id",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "post_views",
"hash": "3DC29B11C7D71D2C29C9FE68F52664F244D6DF2F4372A9F6BD135BD89CAD10B4",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,342 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "title_column",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "score",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "boolean",
"source": "public",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "citext",
"source": "category",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "\"sponsored\"",
"size": null,
"type": "text",
"source": "type",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "price",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "\"0\"",
"size": null,
"type": "decimal",
"source": "decimal",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "status",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "status",
"source": "status_enum",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"float"
],
"source": "point",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "custom_point",
"source": "composite_point",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "map",
"source": "stuff",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"map"
],
"source": "list_of_stuff",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_one",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_two",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_custom_one",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_custom_two",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"text"
],
"source": "list_containing_nils",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "organization_id",
"references": {
"name": "posts_organization_id_fkey",
"table": "orgs",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "author_id",
"references": {
"name": "posts_author_id_fkey",
"table": "authors",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "posts",
"hash": "6BDD92F513B8CE90C615521D5D28BF89F5DFA5C70F7A889EBEB733CA4163B75E",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [
{
"name": "uniq_one_and_two",
"keys": [
"uniq_one",
"uniq_two"
],
"base_filter": "type = 'sponsored'",
"all_tenants?": false,
"index_name": "posts_uniq_one_and_two_index"
}
],
"has_create_action": true,
"custom_indexes": [
{
"message": "dude what the heck",
"name": null,
"table": null,
"include": null,
"fields": [
{
"type": "atom",
"value": "uniq_custom_one"
},
{
"type": "atom",
"value": "uniq_custom_two"
}
],
"prefix": null,
"where": null,
"unique": true,
"concurrently": true,
"all_tenants?": false,
"error_fields": [
"uniq_custom_one",
"uniq_custom_two"
],
"nulls_distinct": true,
"using": null
}
],
"custom_statements": [],
"base_filter": "type = 'sponsored'",
"check_constraints": [
{
"name": "price_must_be_positive",
"check": "price > 0",
"attribute": [
"price"
],
"base_filter": "type = 'sponsored'"
}
]
}

View file

@ -0,0 +1,342 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "title_column",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "score",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "boolean",
"source": "public",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "citext",
"source": "category",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "\"sponsored\"",
"size": null,
"type": "text",
"source": "type",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "bigint",
"source": "price",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "\"0\"",
"size": null,
"type": "decimal",
"source": "decimal",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "status",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "status",
"source": "status_enum",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"float"
],
"source": "point",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "custom_point",
"source": "composite_point",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "map",
"source": "stuff",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"map"
],
"source": "list_of_stuff",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_one",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_two",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_custom_one",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "uniq_custom_two",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": [
"array",
"text"
],
"source": "list_containing_nils",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "created_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "organization_id",
"references": {
"name": "posts_organization_id_fkey",
"table": "orgs",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "author_id",
"references": {
"name": "posts_author_id_fkey",
"table": "authors",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "posts",
"hash": "987D3631D8B6C31C1BA0E5CCF93DDECAFA1CA45768B37AFDEEA9000A09670EF7",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [
{
"name": "uniq_one_and_two",
"keys": [
"uniq_one",
"uniq_two"
],
"base_filter": "type = 'sponsored'",
"all_tenants?": false,
"index_name": "posts_uniq_one_and_two_index"
}
],
"has_create_action": true,
"custom_indexes": [
{
"message": "dude what the heck",
"name": null,
"table": null,
"include": null,
"prefix": null,
"where": null,
"fields": [
{
"type": "atom",
"value": "uniq_custom_one"
},
{
"type": "atom",
"value": "uniq_custom_two"
}
],
"unique": true,
"concurrently": true,
"all_tenants?": false,
"error_fields": [
"uniq_custom_one",
"uniq_custom_two"
],
"nulls_distinct": true,
"using": null
}
],
"custom_statements": [],
"base_filter": "type = 'sponsored'",
"check_constraints": [
{
"name": "price_must_be_positive",
"check": "price > 0",
"attribute": [
"price"
],
"base_filter": "type = 'sponsored'"
}
]
}

View file

@ -0,0 +1,67 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "description",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "author_id",
"references": {
"name": "profile_author_id_fkey",
"table": "authors",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "profile",
"hash": "4D5319352707FBF8EEEC4221C202ABF4F77AFE3A931697795D125CBB87F8F78C",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": "profiles",
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,59 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "full_name",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "records",
"hash": "4947993D236ABA95A54A3AEAB01748894D857344F72470EF124993FD8E098C35",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,59 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "full_name",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "records",
"hash": "F112A3BEAA12D1FC73C33D960C3E9A9777095B15859A297E0A2EC9B8FEE8E8A7",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,59 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "full_name",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"now()\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "temp_entities",
"hash": "B6BCD5D4F436B5B11C6502095CC3157DC75E3AEE723AAC8A8455500D59F1F8EE",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": "temp",
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,59 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "full_name",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "inserted_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
},
{
"default": "fragment(\"(now() AT TIME ZONE 'utc')\")",
"size": null,
"type": "utc_datetime_usec",
"source": "updated_at",
"references": null,
"primary_key?": false,
"allow_nil?": false,
"generated?": false
}
],
"table": "temp_entities",
"hash": "96A9F379FDC5364E80B0E424BFF3F43F58733AB25F6CDF5F921E36D4261E6AE1",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": "temp",
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,95 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "org_id",
"references": {
"name": "multitenant_posts_org_id_fkey",
"table": "multitenant_orgs",
"multitenancy": {
"global": true,
"attribute": "id",
"strategy": "attribute"
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "user_id",
"references": {
"name": "multitenant_posts_user_id_fkey",
"table": "users",
"multitenancy": {
"global": true,
"attribute": "org_id",
"strategy": "attribute"
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "multitenant_posts",
"hash": "9B4FF881274BB3A9AF5DFCBDB80B33E9C213326DD3ACCFFC23FF0B45B7059461",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": false,
"attribute": null,
"strategy": "context"
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,105 @@
{
"attributes": [
{
"default": "fragment(\"gen_random_uuid()\")",
"size": null,
"type": "uuid",
"source": "id",
"references": null,
"primary_key?": true,
"allow_nil?": false,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "boolean",
"source": "is_active",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "text",
"source": "name",
"references": null,
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "organization_id",
"references": {
"name": "users_organization_id_fkey",
"table": "orgs",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
},
{
"default": "nil",
"size": null,
"type": "uuid",
"source": "org_id",
"references": {
"name": "users_org_id_fkey",
"table": "multitenant_orgs",
"multitenancy": {
"global": true,
"attribute": "id",
"strategy": "attribute"
},
"primary_key?": true,
"destination_attribute": "id",
"schema": "public",
"deferrable": false,
"destination_attribute_default": null,
"destination_attribute_generated": null,
"on_delete": null,
"on_update": null,
"match_with": null,
"match_type": null
},
"primary_key?": false,
"allow_nil?": true,
"generated?": false
}
],
"table": "users",
"hash": "1E8931B282681C15BD83551B4849F1C6C8C9755D45A28AEE9617527DB1DD3921",
"repo": "Elixir.AshPostgres.TestRepo",
"multitenancy": {
"global": null,
"attribute": null,
"strategy": null
},
"schema": null,
"identities": [],
"has_create_action": true,
"custom_indexes": [],
"custom_statements": [],
"base_filter": null,
"check_constraints": []
}

View file

@ -0,0 +1,209 @@
defmodule AshPostgres.TestRepo.Migrations.MigrateResources19 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(:users) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:temp_entities, prefix: "temp") do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:records) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:profile, prefix: "profiles") do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:posts) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
drop(constraint(:post_ratings, "post_ratings_resource_id_fkey"))
alter table(:post_ratings) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
modify(
:resource_id,
references(:posts, column: :id, name: "post_ratings_resource_id_fkey", type: :uuid)
)
end
alter table(:post_followers) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:orgs) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:multitenant_orgs) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:managers) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:entities) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:complex_calculations_skills) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:complex_calculations_documentations) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:complex_calculations_channels) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:complex_calculations_certifications_channel_members) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:complex_calculations_certifications) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:comments) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
drop(constraint(:comment_ratings, "comment_ratings_resource_id_fkey"))
alter table(:comment_ratings) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
modify(
:resource_id,
references(:comments, column: :id, name: "comment_ratings_resource_id_fkey", type: :uuid)
)
end
alter table(:authors) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
alter table(:accounts) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
execute(
"ALTER TABLE comment_ratings alter CONSTRAINT comment_ratings_resource_id_fkey NOT DEFERRABLE"
)
execute(
"ALTER TABLE post_ratings alter CONSTRAINT post_ratings_resource_id_fkey NOT DEFERRABLE"
)
end
def down do
alter table(:accounts) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:authors) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
drop(constraint(:comment_ratings, "comment_ratings_resource_id_fkey"))
alter table(:comment_ratings) do
modify(
:resource_id,
references(:comments, column: :id, name: "comment_ratings_resource_id_fkey", type: :uuid)
)
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:comments) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:complex_calculations_certifications) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:complex_calculations_certifications_channel_members) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:complex_calculations_channels) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:complex_calculations_documentations) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:complex_calculations_skills) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:entities) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:managers) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:multitenant_orgs) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:orgs) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:post_followers) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
drop(constraint(:post_ratings, "post_ratings_resource_id_fkey"))
alter table(:post_ratings) do
modify(
:resource_id,
references(:posts, column: :id, name: "post_ratings_resource_id_fkey", type: :uuid)
)
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:posts) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:profile, prefix: "profiles") do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:records) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:temp_entities, prefix: "temp") do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
alter table(:users) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
end
end

View file

@ -0,0 +1,99 @@
defmodule AshPostgres.TestRepo.Migrations.MigrateResources20 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(:temp_entities, prefix: "temp") do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:records) do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:posts) do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:post_views) do
modify(:time, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:entities) do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:complex_calculations_documentations) do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:inserted_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:complex_calculations_channels) do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:complex_calculations_certifications_channel_members) do
modify(:updated_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
alter table(:comments) do
modify(:created_at, :utc_datetime_usec, default: fragment("(now() AT TIME ZONE 'utc')"))
end
end
def down do
alter table(:comments) do
modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:complex_calculations_certifications_channel_members) do
modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:complex_calculations_channels) do
modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:complex_calculations_documentations) do
modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:entities) do
modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:post_views) do
modify(:time, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:posts) do
modify(:created_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:records) do
modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
alter table(:temp_entities, prefix: "temp") do
modify(:inserted_at, :utc_datetime_usec, default: fragment("now()"))
modify(:updated_at, :utc_datetime_usec, default: fragment("now()"))
end
end
end

View file

@ -0,0 +1,21 @@
defmodule AshPostgres.TestRepo.TenantMigrations.MigrateResources2 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(:multitenant_posts, prefix: prefix()) do
modify(:id, :uuid, default: fragment("gen_random_uuid()"))
end
end
def down do
alter table(:multitenant_posts, prefix: prefix()) do
modify(:id, :uuid, default: fragment("uuid_generate_v4()"))
end
end
end