Skip to content

Commit

Permalink
Update migration
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrel-b committed Oct 23, 2023
1 parent 1e9ce77 commit 6267083
Show file tree
Hide file tree
Showing 18 changed files with 889 additions and 146 deletions.
493 changes: 493 additions & 0 deletions cmd/token_normalization_migrate/main.go

Large diffs are not rendered by default.

56 changes: 28 additions & 28 deletions db/gen/coredb/batch.go

Large diffs are not rendered by default.

36 changes: 33 additions & 3 deletions db/gen/coredb/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 51 additions & 51 deletions db/gen/coredb/query.sql.go

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions db/gen/coredb/tmp_token_normalization_backfill.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions db/gen/coredb/token_gallery.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 0 additions & 54 deletions db/migrations/core/000111_add_token_definitions.up.sql

This file was deleted.

24 changes: 24 additions & 0 deletions db/migrations/core/000111_token_norm_add_token_definitions.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
-- Ensures that changes to a contract are mirrored in the token_definitions table. A unique constraint on (chain, address) already exists to guarantee uniqueness within the table itself.
create unique index contracts_id_chain_address_idx on contracts(id, chain, address);

create table if not exists token_definitions (
id character varying(255) primary key,
created_at timestamp with time zone not null default current_timestamp,
last_updated timestamp with time zone not null default current_timestamp,
deleted boolean not null default false,
name character varying,
description character varying,
token_type character varying,
token_id character varying,
external_url character varying,
chain integer,
metadata jsonb,
fallback_media jsonb,
contract_address character varying(255) not null,
contract_id character varying(255) references contracts(id) not null,
token_media_id character varying(255) references token_medias(id),
foreign key(contract_id, chain, contract_address) references contracts(id, chain, address) on update cascade
);
create unique index if not exists token_definitions_chain_contract_id_token_idx on token_definitions(chain, contract_id, token_id) where not deleted;
create unique index if not exists token_definitions_chain_contract_address_token_idx on token_definitions(chain, contract_address, token_id) where not deleted;
create index token_definitions_contract_id_idx on token_definitions(contract_id) where not deleted;
Loading

0 comments on commit 6267083

Please sign in to comment.