From dae5d2949837508f3667b4e13aa1df76a8666bc8 Mon Sep 17 00:00:00 2001 From: mistakia <1823355+mistakia@users.noreply.github.com> Date: Tue, 18 Jun 2024 12:24:47 -0400 Subject: [PATCH] fix: changelog table indexes --- .github/workflows/test.yml | 1 - db/schema.sql | 4 ++-- docs/cli.md | 14 ++++++------- libs-server/update-account.mjs | 23 +++++++++++++++------- libs-server/update-representative-meta.mjs | 23 +++++++++++++++------- 5 files changed, 41 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9e70fc2b..9c1ec90d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -41,7 +41,6 @@ jobs: YARN_CHECKSUM_BEHAVIOR=update yarn install cd .. - - name: yarn lint env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/db/schema.sql b/db/schema.sql index 52a5594c..78e0bd97 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -30,7 +30,7 @@ CREATE TABLE `accounts_changelog` ( `previous_value` varchar(1000) CHARACTER SET utf8mb4 DEFAULT '', `new_value` varchar(1000) CHARACTER SET utf8mb4 DEFAULT '', `timestamp` int(11) NOT NULL, - UNIQUE `change` (`account`, `column`, `previous_value`(60), `new_value`(60)) + UNIQUE `change` (`account`, `column`, `previous_value`(60), `new_value`(60), `timestamp`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci; -- ---------------------------------------------------------- @@ -353,7 +353,7 @@ CREATE TABLE `representatives_meta_index_changelog` ( `previous_value` varchar(1000) CHARACTER SET utf8mb4 DEFAULT '', `new_value` varchar(1000) CHARACTER SET utf8mb4 DEFAULT '', `timestamp` int(11) NOT NULL, - UNIQUE `change` (`account`, `column`, `previous_value`(60), `new_value`(60)) + UNIQUE `change` (`account`, `column`, `previous_value`(55), `new_value`(55), `timestamp`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci; -- -------------------------------------------------------- diff --git a/docs/cli.md b/docs/cli.md index 3ab4e492..d58eb62d 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -11,13 +11,13 @@ tags: nano, xno, cli, nano-community, alias, representative, metadata, signing k The Nano.Community CLI is available as a global npm package. You'll need to have [Node.js installed](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to use it. ```bash -npm install -g nano-community +npm install -g nano-community-cli ``` It is also available as a yarn global package. ```bash -yarn global add nano-community +yarn global add nano-community-cli ``` ### Setting Environment Variables (optional) @@ -37,21 +37,21 @@ Choose the method that best suits your security and convenience needs. You can set the environment variable for a single command by passing it as an argument. ```bash -NC_CLI_NANO_PRIVATE_KEY='your_private_key_here' nano-community update-rep-meta +NC_CLI_NANO_PRIVATE_KEY='' nano-community update-rep-meta ``` #### Setting the environment variable for a single session -**Linux/Mac:** +##### Linux/Mac: ```bash -export NC_CLI_NANO_PRIVATE_KEY='your_private_key_here' +export NC_CLI_NANO_PRIVATE_KEY='' ``` -**Windows:** +##### Windows: ```cmd -set NC_CLI_NANO_PRIVATE_KEY=your_private_key_here +set NC_CLI_NANO_PRIVATE_KEY= ``` This will persist for the duration of the current session in the terminal. You can now run commands without having to set the environment variable for each command. diff --git a/libs-server/update-account.mjs b/libs-server/update-account.mjs index ae6ba215..a7dd1885 100644 --- a/libs-server/update-account.mjs +++ b/libs-server/update-account.mjs @@ -84,13 +84,22 @@ export default async function update_account({ const has_existing_value = edit.lhs if (has_existing_value) { - await db('accounts_changelog').insert({ - account: account_row.account, - column: prop, - previous_value: edit.lhs, - new_value: edit.rhs, - timestamp: Math.floor(Date.now() / 1000) - }) + await db('accounts_changelog') + .insert({ + account: account_row.account, + column: prop, + previous_value: edit.lhs, + new_value: edit.rhs, + timestamp: Math.floor(Date.now() / 1000) + }) + .onConflict([ + 'account', + 'column', + 'previous_value', + 'new_value', + 'timestamp' + ]) + .ignore() } await db('accounts') diff --git a/libs-server/update-representative-meta.mjs b/libs-server/update-representative-meta.mjs index b313be41..6e0d606c 100644 --- a/libs-server/update-representative-meta.mjs +++ b/libs-server/update-representative-meta.mjs @@ -97,13 +97,22 @@ export default async function update_representative_meta({ const has_existing_value = edit.lhs if (has_existing_value) { - await db('representatives_meta_index_changelog').insert({ - account: representative_row.account, - column: prop, - previous_value: edit.lhs, - new_value: edit.rhs, - timestamp: Math.floor(Date.now() / 1000) - }) + await db('representatives_meta_index_changelog') + .insert({ + account: representative_row.account, + column: prop, + previous_value: edit.lhs, + new_value: edit.rhs, + timestamp: Math.floor(Date.now() / 1000) + }) + .onConflict([ + 'account', + 'column', + 'previous_value', + 'new_value', + 'timestamp' + ]) + .ignore() } await db('representatives_meta_index')