-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
update schema.graphql with denormalized schema #132
Draft
MarioBassem
wants to merge
5
commits into
master
Choose a base branch
from
master_denormalize_data
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+362
−380
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
47c15b2
update schema.graphql with denormalized schema
MarioBassem 7333d01
update auto-generated types
MarioBassem e35497f
update type mappings
MarioBassem 5ca1f5a
update db migrations
MarioBassem 4ca6b15
fix farm free ips & node free resources calculations
MarioBassem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
module.exports = class denormalize_data1694605589133 { | ||
name = 'denormalize_data1694605589133' | ||
|
||
async up(db) { | ||
await db.query(`CREATE TABLE "contract" ("id" character varying NOT NULL, "grid_version" integer NOT NULL, "contract_id" numeric NOT NULL, "twin_id" integer NOT NULL, "node_id" integer, "deployment_data" text, "deployment_hash" text, "number_of_public_i_ps" integer, "state" character varying(11) NOT NULL, "created_at" numeric NOT NULL, "solution_provider_id" integer, "used_cru" numeric, "used_mru" numeric, "used_sru" numeric, "used_hru" numeric, "name" text, "type" character varying(4) NOT NULL, CONSTRAINT "PK_17c3a89f58a2997276084e706e8" PRIMARY KEY ("id"))`) | ||
await db.query(`CREATE INDEX "IDX_2f25fae55a3bd80337501b310e" ON "contract" ("contract_id") `) | ||
await db.query(`CREATE INDEX "IDX_e9713e5dd661bc93d698d725e8" ON "contract" ("state") `) | ||
await db.query(`CREATE INDEX "IDX_59d5a7aca69d7ea58c101a44c6" ON "contract" ("type") `) | ||
await db.query(`ALTER TABLE "farm" ADD "total_ips" integer NOT NULL`) | ||
await db.query(`ALTER TABLE "farm" ADD "free_ips" integer NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "total_cru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "total_hru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "total_sru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "total_mru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "free_mru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "free_hru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "free_sru" numeric NOT NULL`) | ||
await db.query(`ALTER TABLE "node" ADD "rented_by" integer`) | ||
await db.query(`ALTER TABLE "public_ip" ALTER COLUMN "contract_id" DROP NOT NULL`) | ||
await db.query(`CREATE INDEX "IDX_a162f043823849732649d40627" ON "twin" ("twin_id") `) | ||
await db.query(`CREATE INDEX "IDX_5f29012fe3403c0cf194457ecd" ON "public_ip" ("contract_id") `) | ||
await db.query(`CREATE INDEX "IDX_a09d726d0ff006b47ff4d25428" ON "farm" ("farm_id") `) | ||
await db.query(`CREATE INDEX "IDX_e6523793483b172e422dc225ad" ON "node" ("node_id") `) | ||
await db.query(`CREATE INDEX "IDX_4d4375648edaa07add3df9d876" ON "node" ("free_mru") `) | ||
await db.query(`CREATE INDEX "IDX_b6ff61e1f0b66b70374d1168d4" ON "node" ("free_hru") `) | ||
await db.query(`CREATE INDEX "IDX_1d93b5617168669d707d52077d" ON "node" ("free_sru") `) | ||
await db.query(`CREATE INDEX "IDX_23c232066e25d61f3a703b1c08" ON "contract_bill_report" ("contract_id") `) | ||
await db.query(`DROP TABLE "rent_contract"`) | ||
await db.query(`DROP TABLE "name_contract"`) | ||
await db.query(`DROP TABLE "contract_resources" cascade`) | ||
await db.query(`DROP TABLE "node_contract" cascade`) | ||
} | ||
|
||
async down(db) { | ||
await db.query(`DROP TABLE "contract"`) | ||
await db.query(`DROP INDEX "public"."IDX_2f25fae55a3bd80337501b310e"`) | ||
await db.query(`DROP INDEX "public"."IDX_e9713e5dd661bc93d698d725e8"`) | ||
await db.query(`DROP INDEX "public"."IDX_59d5a7aca69d7ea58c101a44c6"`) | ||
await db.query(`ALTER TABLE "farm" DROP COLUMN "total_ips"`) | ||
await db.query(`ALTER TABLE "farm" DROP COLUMN "free_ips"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "total_cru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "total_hru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "total_sru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "total_mru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "free_mru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "free_hru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "free_sru"`) | ||
await db.query(`ALTER TABLE "node" DROP COLUMN "rented_by"`) | ||
await db.query(`ALTER TABLE "public_ip" ALTER COLUMN "contract_id" SET NOT NULL`) | ||
await db.query(`DROP INDEX "public"."IDX_a162f043823849732649d40627"`) | ||
await db.query(`DROP INDEX "public"."IDX_5f29012fe3403c0cf194457ecd"`) | ||
await db.query(`DROP INDEX "public"."IDX_a09d726d0ff006b47ff4d25428"`) | ||
await db.query(`DROP INDEX "public"."IDX_e6523793483b172e422dc225ad"`) | ||
await db.query(`DROP INDEX "public"."IDX_4d4375648edaa07add3df9d876"`) | ||
await db.query(`DROP INDEX "public"."IDX_b6ff61e1f0b66b70374d1168d4"`) | ||
await db.query(`DROP INDEX "public"."IDX_1d93b5617168669d707d52077d"`) | ||
await db.query(`DROP INDEX "public"."IDX_23c232066e25d61f3a703b1c08"`) | ||
await db.query(`CREATE TABLE "node_contract" ("id" character varying NOT NULL, "grid_version" integer NOT NULL, "contract_id" numeric NOT NULL, "twin_id" integer NOT NULL, "node_id" integer NOT NULL, "deployment_data" text NOT NULL, "deployment_hash" text NOT NULL, "number_of_public_i_ps" integer NOT NULL, "state" character varying(11) NOT NULL, "created_at" numeric NOT NULL, "resources_used_id" character varying, "solution_provider_id" integer, CONSTRAINT "PK_a5f90b17f504ffcd79d1f66574a" PRIMARY KEY ("id"))`) | ||
await db.query(`ALTER TABLE "node_contract" ADD CONSTRAINT "FK_f294cfb50bb7c7b976d86c08fda" FOREIGN KEY ("resources_used_id") REFERENCES "contract_resources"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) | ||
await db.query(`CREATE TABLE "rent_contract" ("id" character varying NOT NULL, "grid_version" integer NOT NULL, "contract_id" numeric NOT NULL, "twin_id" integer NOT NULL, "node_id" integer NOT NULL, "state" character varying(11) NOT NULL, "created_at" numeric NOT NULL, "solution_provider_id" integer, CONSTRAINT "PK_3c99766b627604d5950d704e33a" PRIMARY KEY ("id"))`) | ||
await db.query(`CREATE TABLE "name_contract" ("id" character varying NOT NULL, "grid_version" integer NOT NULL, "contract_id" numeric NOT NULL, "twin_id" integer NOT NULL, "name" text NOT NULL, "state" character varying(11) NOT NULL, "created_at" numeric NOT NULL, "solution_provider_id" integer, CONSTRAINT "PK_7b4cd056bbb83602d211996360f" PRIMARY KEY ("id"))`) | ||
await db.query(`CREATE TABLE "contract_resources" ("id" character varying NOT NULL, "hru" numeric NOT NULL, "sru" numeric NOT NULL, "cru" numeric NOT NULL, "mru" numeric NOT NULL, "contract_id" character varying, CONSTRAINT "PK_557de19994fcca90916e8c6582f" PRIMARY KEY ("id"))`) | ||
await db.query(`ALTER TABLE "contract_resources" ADD CONSTRAINT "FK_621238dffde9099b2233650235d" FOREIGN KEY ("contract_id") REFERENCES "node_contract"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`) | ||
} | ||
} | ||
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Mario, for all the good work!
Since this PR is about performance, have we conducted any tests or benchmarks to demonstrate the effectiveness of the performance improvements made here?
I would like to see some numbers before and after the changes for the queries that were used in production. This will help us understand the impact of the changes and whether they are worth implementing.
Also, I was wondering if there are any other parts of the system that use this database directly besides gridproxy. If so, it might be helpful to include a note in the PR description about what will be affected by this change.