Skip to content

Commit

Permalink
fix: changelog table indexes
Browse files Browse the repository at this point in the history
  • Loading branch information
mistakia committed Jun 18, 2024
1 parent 5f90c09 commit dae5d29
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 24 deletions.
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ jobs:
YARN_CHECKSUM_BEHAVIOR=update yarn install
cd ..
- name: yarn lint
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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;

-- ----------------------------------------------------------
Expand Down Expand Up @@ -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;

-- --------------------------------------------------------
Expand Down
14 changes: 7 additions & 7 deletions docs/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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='<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='<private_key>'
```

**Windows:**
##### Windows:

```cmd
set NC_CLI_NANO_PRIVATE_KEY=your_private_key_here
set NC_CLI_NANO_PRIVATE_KEY=<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.
Expand Down
23 changes: 16 additions & 7 deletions libs-server/update-account.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
23 changes: 16 additions & 7 deletions libs-server/update-representative-meta.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit dae5d29

Please sign in to comment.