Skip to content

Commit 60b8db0

Browse files
authored
chore!: consolidate db migrations into one file per table (#2392)
* chore: delete some old files, update deps * fix: ts migrations * fix: remove old migration * chore: update to ts migrations * fix: revert to node-pg-migrate v6 * fix: remove old principal_stx_txs refs * fix: default chain tip row * chore: fix migration numbers
1 parent ea49733 commit 60b8db0

File tree

97 files changed

+1290
-3875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+1290
-3875
lines changed

.gitpod.Dockerfile

Lines changed: 0 additions & 23 deletions
This file was deleted.

.gitpod.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

config/extra-tx-post-endpoints.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

migrations/1588256295395_ft_events.js

Lines changed: 0 additions & 83 deletions
This file was deleted.

migrations/1588261750265_nft_events.js

Lines changed: 0 additions & 85 deletions
This file was deleted.
Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */
2-
exports.up = pgm => {
1+
import { MigrationBuilder, ColumnDefinitions } from 'node-pg-migrate';
2+
3+
export const shorthands: ColumnDefinitions | undefined = undefined;
4+
5+
export async function up(pgm: MigrationBuilder): Promise<void> {
36
pgm.createTable('blocks', {
47
index_block_hash: {
58
type: 'bytea',
@@ -69,11 +72,40 @@ exports.up = pgm => {
6972
type: 'bigint',
7073
notNull: true,
7174
},
75+
tx_count: {
76+
type: 'int',
77+
notNull: true,
78+
default: 1,
79+
},
80+
block_time: {
81+
type: 'integer',
82+
notNull: true,
83+
default: '0',
84+
},
85+
signer_bitvec: {
86+
type: 'bit varying',
87+
},
88+
tenure_height: {
89+
type: 'integer',
90+
},
91+
signer_signatures: {
92+
type: 'bytea[]',
93+
},
94+
tx_total_size: {
95+
type: 'int',
96+
},
7297
});
7398

7499
pgm.createIndex('blocks', 'block_hash', { method: 'hash' });
75-
pgm.createIndex('blocks', 'burn_block_hash', { method: 'hash' });
76-
pgm.createIndex('blocks', 'index_block_hash', { method: 'hash' });
77100
pgm.createIndex('blocks', [{ name: 'block_height', sort: 'DESC' }]);
101+
pgm.createIndex('blocks', 'burn_block_hash', { method: 'hash' });
78102
pgm.createIndex('blocks', [{ name: 'burn_block_height', sort: 'DESC' }]);
103+
pgm.createIndex('blocks', 'index_block_hash', { method: 'hash' });
104+
pgm.createIndex('blocks', 'signer_signatures', { method: 'gin' });
105+
pgm.createIndex('blocks', ['tenure_height', { name: 'block_height', sort: 'DESC' }]);
106+
}
107+
108+
export async function down(pgm: MigrationBuilder): Promise<void> {
109+
pgm.dropTable('blocks');
79110
}
111+

0 commit comments

Comments
 (0)