diff --git a/db/migrations/1699972446420-Data.js b/db/migrations/1701772484992-Data.js similarity index 98% rename from db/migrations/1699972446420-Data.js rename to db/migrations/1701772484992-Data.js index af7edf8a1..854fcdbce 100644 --- a/db/migrations/1699972446420-Data.js +++ b/db/migrations/1701772484992-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1699972446420 { - name = 'Data1699972446420' +module.exports = class Data1701772484992 { + name = 'Data1701772484992' async up(db) { await db.query(`CREATE TABLE "channel_follow" ("id" character varying NOT NULL, "user_id" character varying, "channel_id" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_9410df2b9a316af3f0d216f9487" PRIMARY KEY ("id"))`) @@ -68,6 +68,7 @@ module.exports = class Data1699972446420 { await db.query(`CREATE INDEX "IDX_73dda64f53bbc7ec7035d5e7f0" ON "video_reaction" ("member_id") `) await db.query(`CREATE INDEX "IDX_436a3836eb47acb5e1e3c88dde" ON "video_reaction" ("video_id") `) await db.query(`CREATE TABLE "video" ("id" character varying NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "channel_id" character varying, "category_id" character varying, "title" text, "description" text, "duration" integer, "thumbnail_photo_id" character varying, "language" text, "has_marketing" boolean, "published_before_joystream" TIMESTAMP WITH TIME ZONE, "is_public" boolean, "is_censored" boolean NOT NULL, "is_excluded" boolean NOT NULL, "is_explicit" boolean, "license_id" character varying, "media_id" character varying, "video_state_bloat_bond" numeric NOT NULL, "created_in_block" integer NOT NULL, "is_comment_section_enabled" boolean NOT NULL, "pinned_comment_id" character varying, "comments_count" integer NOT NULL, "is_reaction_feature_enabled" boolean NOT NULL, "reactions_count_by_reaction_id" jsonb, "reactions_count" integer NOT NULL, "views_num" integer NOT NULL, "entry_app_id" character varying, "yt_video_id" text, "video_relevance" numeric NOT NULL, CONSTRAINT "PK_1a2f3856250765d72e7e1636c8e" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_fe2b4b6aace15f1b6610830846" ON "video" ("created_at") `) await db.query(`CREATE INDEX "IDX_81b11ef99a9db9ef1aed040d75" ON "video" ("channel_id") `) await db.query(`CREATE INDEX "IDX_2a5c61f32e9636ee10821e9a58" ON "video" ("category_id") `) await db.query(`CREATE INDEX "IDX_8530d052cc79b420f7ce2b4e09" ON "video" ("thumbnail_photo_id") `) @@ -83,6 +84,7 @@ module.exports = class Data1699972446420 { await db.query(`CREATE INDEX "IDX_e7618559409a903a897164156b" ON "bid" ("bidder_id") `) await db.query(`CREATE INDEX "IDX_32cb73025ec49c87f4c594a265" ON "bid" ("previous_top_bid_id") `) await db.query(`CREATE TABLE "owned_nft" ("id" character varying NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "video_id" character varying NOT NULL, "owner" jsonb NOT NULL, "transactional_status" jsonb, "creator_royalty" numeric, "last_sale_price" numeric, "last_sale_date" TIMESTAMP WITH TIME ZONE, "is_featured" boolean NOT NULL, CONSTRAINT "OwnedNft_video" UNIQUE ("video_id") DEFERRABLE INITIALLY DEFERRED, CONSTRAINT "REL_466896e39b9ec953f4f2545622" UNIQUE ("video_id"), CONSTRAINT "PK_5e0c289b350e863668fff44bb56" PRIMARY KEY ("id"))`) + await db.query(`CREATE INDEX "IDX_8c7201ed7d4765dcbcc3609356" ON "owned_nft" ("created_at") `) await db.query(`CREATE INDEX "IDX_466896e39b9ec953f4f2545622" ON "owned_nft" ("video_id") `) await db.query(`CREATE TABLE "auction" ("id" character varying NOT NULL, "nft_id" character varying, "winning_member_id" character varying, "starting_price" numeric NOT NULL, "buy_now_price" numeric, "auction_type" jsonb NOT NULL, "top_bid_id" character varying, "starts_at_block" integer NOT NULL, "ended_at_block" integer, "is_canceled" boolean NOT NULL, "is_completed" boolean NOT NULL, CONSTRAINT "PK_9dc876c629273e71646cf6dfa67" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_cfb47e97e60c9d1462576f85a8" ON "auction" ("nft_id") `) @@ -110,6 +112,7 @@ module.exports = class Data1699972446420 { await db.query(`CREATE INDEX "IDX_a6fe18c105f85a63d761ccb078" ON "token" ("issued_for_id") `) await db.query(`CREATE TABLE "event" ("id" character varying NOT NULL, "in_block" integer NOT NULL, "in_extrinsic" text, "index_in_block" integer NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "data" jsonb NOT NULL, CONSTRAINT "PK_30c2f3bbaf6d34a55f8ae6e4614" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_8f3f220c4e717207d841d4e6d4" ON "event" ("in_extrinsic") `) + await db.query(`CREATE INDEX "IDX_2c15918ff289396205521c5f3c" ON "event" ("timestamp") `) await db.query(`CREATE TABLE "notification" ("id" character varying NOT NULL, "member_id" character varying, "event_id" character varying, CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_ac8de39626657d3c0e909d9d82" ON "notification" ("member_id") `) await db.query(`CREATE INDEX "IDX_122be1f0696e0255acf95f9e33" ON "notification" ("event_id") `) @@ -275,6 +278,7 @@ module.exports = class Data1699972446420 { await db.query(`DROP INDEX "public"."IDX_73dda64f53bbc7ec7035d5e7f0"`) await db.query(`DROP INDEX "public"."IDX_436a3836eb47acb5e1e3c88dde"`) await db.query(`DROP TABLE "video"`) + await db.query(`DROP INDEX "public"."IDX_fe2b4b6aace15f1b6610830846"`) await db.query(`DROP INDEX "public"."IDX_81b11ef99a9db9ef1aed040d75"`) await db.query(`DROP INDEX "public"."IDX_2a5c61f32e9636ee10821e9a58"`) await db.query(`DROP INDEX "public"."IDX_8530d052cc79b420f7ce2b4e09"`) @@ -290,6 +294,7 @@ module.exports = class Data1699972446420 { await db.query(`DROP INDEX "public"."IDX_e7618559409a903a897164156b"`) await db.query(`DROP INDEX "public"."IDX_32cb73025ec49c87f4c594a265"`) await db.query(`DROP TABLE "owned_nft"`) + await db.query(`DROP INDEX "public"."IDX_8c7201ed7d4765dcbcc3609356"`) await db.query(`DROP INDEX "public"."IDX_466896e39b9ec953f4f2545622"`) await db.query(`DROP TABLE "auction"`) await db.query(`DROP INDEX "public"."IDX_cfb47e97e60c9d1462576f85a8"`) @@ -317,6 +322,7 @@ module.exports = class Data1699972446420 { await db.query(`DROP INDEX "public"."IDX_a6fe18c105f85a63d761ccb078"`) await db.query(`DROP TABLE "event"`) await db.query(`DROP INDEX "public"."IDX_8f3f220c4e717207d841d4e6d4"`) + await db.query(`DROP INDEX "public"."IDX_2c15918ff289396205521c5f3c"`) await db.query(`DROP TABLE "notification"`) await db.query(`DROP INDEX "public"."IDX_ac8de39626657d3c0e909d9d82"`) await db.query(`DROP INDEX "public"."IDX_122be1f0696e0255acf95f9e33"`) diff --git a/schema/NFTs.graphql b/schema/NFTs.graphql index 1d5930967..113e8c3a2 100644 --- a/schema/NFTs.graphql +++ b/schema/NFTs.graphql @@ -32,7 +32,7 @@ type TransactionalStatusAuction { "Represents NFT details" type OwnedNft @entity { "Timestamp of the block the NFT was created at" - createdAt: DateTime! + createdAt: DateTime! @index "NFT's video" video: Video! @unique diff --git a/schema/events.graphql b/schema/events.graphql index 23453314b..85cba7638 100644 --- a/schema/events.graphql +++ b/schema/events.graphql @@ -12,7 +12,7 @@ type Event @entity { indexInBlock: Int! "Timestamp of the block the event was emitted in" - timestamp: DateTime! + timestamp: DateTime! @index "More specific event data, which depends on event type" data: EventData! diff --git a/schema/videos.graphql b/schema/videos.graphql index 9c96d0999..ce4f9f18c 100644 --- a/schema/videos.graphql +++ b/schema/videos.graphql @@ -26,7 +26,7 @@ type Video @entity { id: ID! "Timestamp of the block the video was created at" - createdAt: DateTime! + createdAt: DateTime! @index "Reference to videos's channel" channel: Channel!