UNPKG

@bsv/overlay

Version:
38 lines 1.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.up = up; exports.down = down; async function up(knex) { // Create the new transactions table await knex.schema.createTable('transactions', table => { table.increments(); table.specificType('beef', 'longblob'); table.string('txid', 64).unique(); }); // Move data from outputs table to the new transactions table and ensure deduplication await knex.raw(` INSERT IGNORE INTO transactions (txid, beef) SELECT txid, beef FROM outputs WHERE beef IS NOT NULL `); // Drop the beef column from the outputs table await knex.schema.table('outputs', table => { table.dropColumn('beef'); }); } async function down(knex) { // Add the beef column back to the outputs table await knex.schema.table('outputs', table => { table.binary('beef'); }); // Move data back from the transactions table to the outputs table using a JOIN await knex.raw(` UPDATE outputs JOIN transactions ON outputs.txid = transactions.txid SET outputs.beef = transactions.beef `); // Drop the transactions table await knex.schema.dropTable('transactions'); } //# sourceMappingURL=2024-07-17-001-transactions.js.map