@lido-nestjs/registry 1.4.5 → 1.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,13 @@ Part of [Lido NestJS Modules](https://github.com/lidofinance/lido-nestjs-modules
9
9
  yarn add @lido-nestjs/registry
10
10
  ```
11
11
 
12
+ ## Migrations
13
+
14
+ Database migrations are placed in `./src/migrations/` folder.
15
+
16
+ Please DO NOT edit migrations, if you want to change the migration,
17
+ please make another one with the needed database schema transitions.
18
+
12
19
  ## Usage
13
20
 
14
21
  TODO
@@ -0,0 +1,15 @@
1
+ import { Migration } from '@mikro-orm/migrations';
2
+ /**
3
+ * PLEASE DO NOT EDIT !!!
4
+ *
5
+ * This migration can be used in the applications that use this module.
6
+ */
7
+ export declare class Migration20220225153937 extends Migration {
8
+ /**
9
+ * @see RegistryKey
10
+ * @see RegistryMeta
11
+ * @see RegistryOperator
12
+ */
13
+ up(): Promise<void>;
14
+ down(): Promise<void>;
15
+ }
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var migrations = require('@mikro-orm/migrations');
6
+
7
+ /**
8
+ * PLEASE DO NOT EDIT !!!
9
+ *
10
+ * This migration can be used in the applications that use this module.
11
+ */
12
+ class Migration20220225153937 extends migrations.Migration {
13
+ /**
14
+ * @see RegistryKey
15
+ * @see RegistryMeta
16
+ * @see RegistryOperator
17
+ */
18
+ async up() {
19
+ /**
20
+ * @see RegistryKey
21
+ */
22
+ this.addSql(`create table "registry_key" (
23
+ "index" int not null,
24
+ "operator_index" int not null,
25
+ "key" varchar(98) not null,
26
+ "deposit_signature" varchar(194) not null,
27
+ "used" boolean not null,
28
+ constraint "registry_key_pkey" primary key ("index", "operator_index"));
29
+ `);
30
+ /**
31
+ * @see RegistryMeta
32
+ */
33
+ this.addSql(`create table "registry_meta" (
34
+ "block_number" serial primary key,
35
+ "block_hash" varchar(66) not null,
36
+ "keys_op_index" int not null,
37
+ "timestamp" int not null);
38
+ `);
39
+ /**
40
+ * @see RegistryOperator
41
+ */
42
+ this.addSql(`create table "registry_operator" (
43
+ "index" serial primary key,
44
+ "active" boolean not null,
45
+ "name" varchar(256) not null,
46
+ "reward_address" varchar(42) not null,
47
+ "staking_limit" int not null,
48
+ "stopped_validators" int not null,
49
+ "total_signing_keys" int not null,
50
+ "used_signing_keys" int not null);
51
+ `);
52
+ }
53
+ async down() {
54
+ /**
55
+ * @see RegistryKey
56
+ */
57
+ this.addSql('drop table if exists "registry_key" cascade;');
58
+ /**
59
+ * @see RegistryMeta
60
+ */
61
+ this.addSql('drop table if exists "registry_meta" cascade;');
62
+ /**
63
+ * @see RegistryOperator
64
+ */
65
+ this.addSql('drop table if exists "registry_operator" cascade;');
66
+ }
67
+ }
68
+
69
+ exports.Migration20220225153937 = Migration20220225153937;
@@ -1,8 +1,7 @@
1
- import { OnModuleDestroy, OnModuleInit } from '@nestjs/common';
1
+ import { OnModuleDestroy } from '@nestjs/common';
2
2
  import { MikroORM } from '@mikro-orm/core';
3
- export declare class RegistryStorageService implements OnModuleInit, OnModuleDestroy {
3
+ export declare class RegistryStorageService implements OnModuleDestroy {
4
4
  private readonly orm;
5
5
  constructor(orm: MikroORM);
6
- onModuleInit(): Promise<void>;
7
6
  onModuleDestroy(): Promise<void>;
8
7
  }
@@ -10,11 +10,6 @@ exports.RegistryStorageService = class RegistryStorageService {
10
10
  constructor(orm) {
11
11
  this.orm = orm;
12
12
  }
13
- async onModuleInit() {
14
- // TODO: think about migrations
15
- const generator = this.orm.getSchemaGenerator();
16
- await generator.updateSchema();
17
- }
18
13
  async onModuleDestroy() {
19
14
  await this.orm.close();
20
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lido-nestjs/registry",
3
- "version": "1.4.5",
3
+ "version": "1.4.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "license": "MIT",
@@ -37,6 +37,7 @@
37
37
  "peerDependencies": {
38
38
  "@mikro-orm/core": "^5.2.0",
39
39
  "@mikro-orm/knex": "^5.2.0",
40
+ "@mikro-orm/migrations": "^5.2.0",
40
41
  "@mikro-orm/nestjs": "^5.0.2",
41
42
  "@nestjs/common": "^8.2.5",
42
43
  "@nestjs/core": "^8.2.5",
@@ -45,9 +46,10 @@
45
46
  "tslib": "^2.3.1"
46
47
  },
47
48
  "devDependencies": {
48
- "@lido-nestjs/execution": "1.8.0",
49
+ "@lido-nestjs/execution": "1.8.2",
49
50
  "@mikro-orm/core": "^5.2.0",
50
51
  "@mikro-orm/knex": "^5.2.0",
52
+ "@mikro-orm/migrations": "^5.2.0",
51
53
  "@mikro-orm/nestjs": "^5.0.2",
52
54
  "@mikro-orm/sqlite": "^5.2.0",
53
55
  "@nestjs/common": "^8.2.5",