-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(bnsv2): added migration files for tables names_v2 and namespaces_v2
- Loading branch information
1 parent
498cb13
commit 392a16b
Showing
2 changed files
with
229 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */ | ||
exports.up = pgm => { | ||
pgm.createTable('names_v2', { | ||
id: { | ||
type: 'serial', | ||
primaryKey: true, | ||
}, | ||
fullName: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
name: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
namespace_id: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
registered_at: { | ||
type: 'integer', | ||
notNull: false, | ||
}, | ||
imported_at: { | ||
type: 'integer', | ||
notNull: false, | ||
}, | ||
hashed_salted_fqn_preorder: { | ||
type: 'string', | ||
notNull: false, | ||
}, | ||
preordered_by: { | ||
type: 'string', | ||
notNull: false, | ||
}, | ||
renewal_height: { | ||
type: 'integer', | ||
notNull: true, | ||
}, | ||
stx_burn: { | ||
type: 'bigint', | ||
notNull: true, | ||
}, | ||
owner: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
tx_id: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
tx_index: { | ||
type: 'smallint', | ||
notNull: true, | ||
}, | ||
event_index: 'integer', | ||
status: { | ||
type: 'string', | ||
notNull: false, | ||
}, | ||
canonical: { | ||
type: 'boolean', | ||
notNull: true, | ||
default: true, | ||
}, | ||
index_block_hash: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
parent_index_block_hash: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
microblock_hash: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
microblock_sequence: { | ||
type: 'integer', | ||
notNull: true, | ||
}, | ||
microblock_canonical: { | ||
type: 'boolean', | ||
notNull: true, | ||
}, | ||
}); | ||
|
||
pgm.createIndex('names_v2', 'namespace_id'); | ||
pgm.createIndex('names_v2', 'index_block_hash'); | ||
pgm.createIndex('names_v2', [ | ||
{ name: 'registered_at', sort: 'DESC' }, | ||
{ name: 'microblock_sequence', sort: 'DESC' }, | ||
{ name: 'tx_index', sort: 'DESC' }, | ||
{ name: 'event_index', sort: 'DESC' }, | ||
]); | ||
pgm.addConstraint( | ||
'names_v2', | ||
'unique_name_v2_tx_id_index_block_hash_microblock_hash_event_index', | ||
'UNIQUE(fullName, tx_id, index_block_hash, microblock_hash, event_index)' | ||
); | ||
pgm.addConstraint('names_v2', 'unique_fullname', 'UNIQUE(fullName)'); | ||
}; | ||
|
||
exports.down = pgm => { | ||
pgm.dropTable('names_v2'); | ||
}; |
123 changes: 123 additions & 0 deletions
123
migrations/20240912154500_add_bns_v2_namespaces_table.js
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,123 @@ | ||
/** @param { import("node-pg-migrate").MigrationBuilder } pgm */ | ||
exports.up = pgm => { | ||
pgm.createTable('namespaces_v2', { | ||
id: { | ||
type: 'serial', | ||
primaryKey: true, | ||
}, | ||
namespace_id: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
namespace_manager: { | ||
type: 'string', | ||
notNull: false, | ||
}, | ||
manager_transferable: { | ||
type: 'boolean', | ||
notNull: true, | ||
}, | ||
manager_frozen: { | ||
type: 'boolean', | ||
notNull: true, | ||
}, | ||
namespace_import: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
reveal_block: { | ||
type: 'integer', | ||
notNull: true, | ||
}, | ||
launched_at: { | ||
type: 'integer', | ||
notNull: false, | ||
}, | ||
launch_block: { | ||
type: 'integer', | ||
notNull: true, | ||
}, | ||
lifetime: { | ||
type: 'integer', | ||
notNull: true, | ||
}, | ||
can_update_price_function: { | ||
type: 'boolean', | ||
notNull: true, | ||
}, | ||
buckets: { | ||
type: 'string', | ||
notNull: true, | ||
}, | ||
base: { | ||
type: 'numeric', | ||
notNull: true, | ||
}, | ||
coeff: { | ||
type: 'numeric', | ||
notNull: true, | ||
}, | ||
nonalpha_discount: { | ||
type: 'numeric', | ||
notNull: true, | ||
}, | ||
no_vowel_discount: { | ||
type: 'numeric', | ||
notNull: true, | ||
}, | ||
status: { | ||
type: 'string', | ||
notNull: false, | ||
}, | ||
tx_id: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
tx_index: { | ||
type: 'smallint', | ||
notNull: true, | ||
}, | ||
canonical: { | ||
type: 'boolean', | ||
notNull: true, | ||
default: true, | ||
}, | ||
index_block_hash: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
parent_index_block_hash: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
microblock_hash: { | ||
type: 'bytea', | ||
notNull: true, | ||
}, | ||
microblock_sequence: { | ||
type: 'integer', | ||
notNull: true, | ||
}, | ||
microblock_canonical: { | ||
type: 'boolean', | ||
notNull: true, | ||
}, | ||
}); | ||
|
||
pgm.createIndex('namespaces_v2', 'index_block_hash'); | ||
pgm.createIndex('namespaces_v2', [ | ||
{ name: 'launch_block', sort: 'DESC' }, | ||
{ name: 'microblock_sequence', sort: 'DESC' }, | ||
{ name: 'tx_index', sort: 'DESC' }, | ||
]); | ||
pgm.addConstraint( | ||
'namespaces_v2', | ||
'unique_namespace_v2_id_tx_id_index_block_hash_microblock_hash', | ||
'UNIQUE(namespace_id, tx_id, index_block_hash, microblock_hash)' | ||
); | ||
pgm.addConstraint('namespaces_v2', 'unique_namespace_id', 'UNIQUE(namespace_id)'); | ||
}; | ||
|
||
exports.down = pgm => { | ||
pgm.dropTable('namespaces_v2'); | ||
}; |