Skip to content

Commit

Permalink
fix: migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Amuhar committed Sep 3, 2023
1 parent dfaa57a commit 573999f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20230901084215 extends Migration {
export class Migration20230903183749 extends Migration {
async up(): Promise<void> {
this.addSql('TRUNCATE registry_key');
this.addSql('TRUNCATE registry_operator');
Expand All @@ -11,7 +11,7 @@ export class Migration20230901084215 extends Migration {
);

this.addSql(
'create table "sr_module_entity" ("id" serial primary key, "module_id" int not null, "staking_module_address" varchar(42) not null, "staking_module_fee" int not null, "target_share" int not null, "status" int not null, "name" varchar(255) not null, "last_deposit_at" int not null, "last_deposit_block" int not null, "exited_validators_count" int not null, "type" varchar(255) not null, "active" boolean not null, "nonce" int not null);',
'create table "sr_module_entity" ("id" serial primary key, "module_id" int not null, "staking_module_address" varchar(42) not null, "staking_module_fee" int not null, "treasury_fee" int not null, "target_share" int not null, "status" int not null, "name" varchar(255) not null, "last_deposit_at" int not null, "last_deposit_block" int not null, "exited_validators_count" int not null, "type" varchar(255) not null, "active" boolean not null, "nonce" int not null);',
);
this.addSql(
'alter table "sr_module_entity" add constraint "sr_module_entity_module_id_unique" unique ("module_id");',
Expand All @@ -22,18 +22,6 @@ export class Migration20230901084215 extends Migration {

this.addSql('drop table if exists "registry_meta" cascade;');

this.addSql('alter table "consensus_meta" alter column "id" type smallint using ("id"::smallint);');
this.addSql('alter table "consensus_meta" alter column "id" set default 0;');
this.addSql('alter table "consensus_meta" drop constraint "consensus_meta_pkey";');
this.addSql('alter table "consensus_meta" add constraint "consensus_meta_id_unique" unique ("id");');
this.addSql(
'alter table "consensus_meta" add constraint "consensus_meta_pkey" primary key ("id", "block_number");',
);

this.addSql('alter table "consensus_validator" drop constraint "index";');
this.addSql('create index "consensus_validator_index_index" on "consensus_validator" ("index");');
this.addSql('alter index "idx_consensus_validator__status" rename to "consensus_validator_status_index";');

this.addSql('alter table "registry_key" add column "module_address" varchar(255) not null;');
this.addSql('alter table "registry_key" drop constraint "registry_key_pkey";');
this.addSql(
Expand Down Expand Up @@ -64,16 +52,6 @@ export class Migration20230901084215 extends Migration {

this.addSql('drop table if exists "sr_module_entity" cascade;');

this.addSql('alter table "consensus_meta" alter column "id" drop default;');
this.addSql('alter table "consensus_meta" alter column "id" type int2 using ("id"::int2);');
this.addSql('alter table "consensus_meta" drop constraint "consensus_meta_id_unique";');
this.addSql('alter table "consensus_meta" drop constraint "consensus_meta_pkey";');
this.addSql('alter table "consensus_meta" add constraint "consensus_meta_pkey" primary key ("id");');

this.addSql('drop index "consensus_validator_index_index";');
this.addSql('alter table "consensus_validator" add constraint "index" unique ("index");');
this.addSql('alter index "consensus_validator_status_index" rename to "idx_consensus_validator__status";');

this.addSql('alter table "registry_key" drop constraint "registry_key_pkey";');
this.addSql('alter table "registry_key" drop column "module_address";');
this.addSql(
Expand Down
1 change: 1 addition & 0 deletions src/storage/sr-module.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export class SrModuleEntity {
stakingModuleFee: number;

// part of the fee taken from staking rewards that goes to the treasury
@Property()
treasuryFee: number;

// target percent of total validators in protocol, in BP
Expand Down

0 comments on commit 573999f

Please sign in to comment.