@nina-protocol/nina-db 0.0.124 → 0.0.126

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/dist/knexfile.js CHANGED
@@ -16,7 +16,10 @@ export default {
16
16
  password: process.env.POSTGRES_PASSWORD,
17
17
  },
18
18
  migrations: {
19
- directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
19
+ directory: [
20
+ './node_modules/@nina-protocol/nina-db/dist/migrations',
21
+ join(__dirname, '../migrations'),
22
+ ],
20
23
  },
21
24
  auth: {
22
25
  client: 'postgresql',
@@ -37,7 +40,10 @@ export default {
37
40
  password: process.env.POSTGRES_PASSWORD,
38
41
  },
39
42
  migrations: {
40
- directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
43
+ directory: [
44
+ './node_modules/@nina-protocol/nina-db/dist/migrations',
45
+ join(__dirname, '../migrations'),
46
+ ],
41
47
  },
42
48
  auth: {
43
49
  client: 'postgresql',
@@ -58,7 +64,10 @@ export default {
58
64
  password: process.env.POSTGRES_PASSWORD,
59
65
  },
60
66
  migrations: {
61
- directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
67
+ directory: [
68
+ './node_modules/@nina-protocol/nina-db/dist/migrations',
69
+ join(__dirname, '../migrations'),
70
+ ],
62
71
  },
63
72
  auth: {
64
73
  client: 'postgresql',
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function (knex) {
6
+ return knex.schema.alterTable('accounts', (table) => {
7
+ table.timestamp('deleted_at').nullable();
8
+ });
9
+ };
10
+ /**
11
+ * @param { import("knex").Knex } knex
12
+ * @returns { Promise<void> }
13
+ */
14
+ export const down = function (knex) {
15
+ return knex.schema.alterTable('accounts', (table) => {
16
+ table.dropColumn('deleted_at');
17
+ });
18
+ };
@@ -17,6 +17,7 @@ export default class Account extends Model {
17
17
  description: { type: 'string' },
18
18
  displayName: { type: 'string' },
19
19
  handle: { type: 'string' },
20
+ deleted_at: { type: ['string', 'null'] },
20
21
  },
21
22
  };
22
23
  static findOrCreate = async (publicKey) => {
@@ -25,9 +25,11 @@ class Post extends Model {
25
25
  }
26
26
  async format(options = {}) {
27
27
  const { includeBlocks = true } = options;
28
- const publisher = await this.$relatedQuery('publisher').select('publicKey');
28
+ const publisher = await this.$relatedQuery('publisher');
29
29
  const publishedThroughHub = await this.$relatedQuery('publishedThroughHub');
30
+ await publisher.format();
30
31
  this.publisher = publisher.publicKey;
32
+ this.publisherAccount = publisher;
31
33
  if (publishedThroughHub) {
32
34
  this.publishedThroughHub = publishedThroughHub.publicKey;
33
35
  this.hub = publishedThroughHub;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nina-protocol/nina-db",
3
- "version": "0.0.124",
3
+ "version": "0.0.126",
4
4
  "description": "",
5
5
  "source": "src/index.js",
6
6
  "main": "dist/index.js",
package/src/knexfile.js CHANGED
@@ -18,7 +18,10 @@ export default {
18
18
  password: process.env.POSTGRES_PASSWORD,
19
19
  },
20
20
  migrations: {
21
- directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
21
+ directory: [
22
+ './node_modules/@nina-protocol/nina-db/dist/migrations',
23
+ join(__dirname, '../migrations'),
24
+ ],
22
25
  },
23
26
  auth: {
24
27
  client: 'postgresql',
@@ -39,7 +42,10 @@ export default {
39
42
  password: process.env.POSTGRES_PASSWORD,
40
43
  },
41
44
  migrations: {
42
- directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
45
+ directory: [
46
+ './node_modules/@nina-protocol/nina-db/dist/migrations',
47
+ join(__dirname, '../migrations'),
48
+ ],
43
49
  },
44
50
  auth: {
45
51
  client: 'postgresql',
@@ -60,7 +66,10 @@ export default {
60
66
  password: process.env.POSTGRES_PASSWORD,
61
67
  },
62
68
  migrations: {
63
- directory: './node_modules/@nina-protocol/nina-db/dist/migrations',
69
+ directory: [
70
+ './node_modules/@nina-protocol/nina-db/dist/migrations',
71
+ join(__dirname, '../migrations'),
72
+ ],
64
73
  },
65
74
  auth: {
66
75
  client: 'postgresql',
@@ -0,0 +1,20 @@
1
+ /**
2
+ * @param { import("knex").Knex } knex
3
+ * @returns { Promise<void> }
4
+ */
5
+ export const up = function(knex) {
6
+ return knex.schema.alterTable('accounts', (table) => {
7
+ table.timestamp('deleted_at').nullable();
8
+ });
9
+
10
+ };
11
+
12
+ /**
13
+ * @param { import("knex").Knex } knex
14
+ * @returns { Promise<void> }
15
+ */
16
+ export const down = function(knex) {
17
+ return knex.schema.alterTable('accounts', (table) => {
18
+ table.dropColumn('deleted_at');
19
+ });
20
+ };
@@ -20,6 +20,7 @@ export default class Account extends Model {
20
20
  description: { type: 'string' },
21
21
  displayName: { type: 'string' },
22
22
  handle: { type: 'string' },
23
+ deleted_at: { type: ['string', 'null'] },
23
24
  },
24
25
  }
25
26
 
@@ -28,10 +28,12 @@ class Post extends Model {
28
28
  async format(options = {}) {
29
29
  const { includeBlocks = true } = options;
30
30
 
31
- const publisher = await this.$relatedQuery('publisher').select('publicKey');
31
+ const publisher = await this.$relatedQuery('publisher');
32
32
  const publishedThroughHub = await this.$relatedQuery('publishedThroughHub');
33
33
 
34
+ await publisher.format();
34
35
  this.publisher = publisher.publicKey;
36
+ this.publisherAccount = publisher;
35
37
  if (publishedThroughHub) {
36
38
  this.publishedThroughHub = publishedThroughHub.publicKey;
37
39
  this.hub = publishedThroughHub;