-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add back legacy accounts table for now (#10450)
- Loading branch information
Showing
7 changed files
with
88 additions
and
2 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
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
18 changes: 18 additions & 0 deletions
18
...ber-privacy/signer/src/common/database/migrations/20200330212224_create-accounts-table.ts
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,18 @@ | ||
import { Knex } from 'knex' | ||
import { ACCOUNTS_COLUMNS, ACCOUNTS_TABLE } from '../models/account' | ||
|
||
export async function up(knex: Knex): Promise<any> { | ||
// This check was necessary to switch from using .ts migrations to .js migrations. | ||
if (!(await knex.schema.hasTable(ACCOUNTS_TABLE.LEGACY))) { | ||
return knex.schema.createTable(ACCOUNTS_TABLE.LEGACY, (t) => { | ||
t.string(ACCOUNTS_COLUMNS.address).notNullable().primary() | ||
t.dateTime(ACCOUNTS_COLUMNS.createdAt).notNullable() | ||
t.integer(ACCOUNTS_COLUMNS.numLookups).unsigned() | ||
}) | ||
} | ||
return null | ||
} | ||
|
||
export async function down(knex: Knex): Promise<any> { | ||
return knex.schema.dropTable(ACCOUNTS_TABLE.LEGACY) | ||
} |
23 changes: 23 additions & 0 deletions
23
...ber-privacy/signer/src/common/database/migrations/20200811163913_create_requests_table.ts
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,23 @@ | ||
import { Knex } from 'knex' | ||
import { REQUESTS_COLUMNS, REQUESTS_TABLE } from '../models/request' | ||
|
||
export async function up(knex: Knex): Promise<any> { | ||
// This check was necessary to switch from using .ts migrations to .js migrations. | ||
if (!(await knex.schema.hasTable(REQUESTS_TABLE.LEGACY))) { | ||
return knex.schema.createTable(REQUESTS_TABLE.LEGACY, (t) => { | ||
t.string(REQUESTS_COLUMNS.address).notNullable() | ||
t.dateTime(REQUESTS_COLUMNS.timestamp).notNullable() | ||
t.string(REQUESTS_COLUMNS.blindedQuery).notNullable() | ||
t.primary([ | ||
REQUESTS_COLUMNS.address, | ||
REQUESTS_COLUMNS.timestamp, | ||
REQUESTS_COLUMNS.blindedQuery, | ||
]) | ||
}) | ||
} | ||
return null | ||
} | ||
|
||
export async function down(knex: Knex): Promise<any> { | ||
return knex.schema.dropTable(REQUESTS_TABLE.LEGACY) | ||
} |
17 changes: 17 additions & 0 deletions
17
...one-number-privacy/signer/src/common/database/migrations/20210421212301_create-indices.ts
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,17 @@ | ||
import { Knex } from 'knex' | ||
import { ACCOUNTS_COLUMNS, ACCOUNTS_TABLE } from '../models/account' | ||
|
||
export async function up(knex: Knex): Promise<any> { | ||
if (!(await knex.schema.hasTable(ACCOUNTS_TABLE.LEGACY))) { | ||
throw new Error('Unexpected error: Could not find ACCOUNTS_TABLE.LEGACY') | ||
} | ||
return knex.schema.alterTable(ACCOUNTS_TABLE.LEGACY, (t) => { | ||
t.index(ACCOUNTS_COLUMNS.address) | ||
}) | ||
} | ||
|
||
export async function down(knex: Knex): Promise<any> { | ||
return knex.schema.alterTable(ACCOUNTS_TABLE.LEGACY, (t) => { | ||
t.dropIndex(ACCOUNTS_COLUMNS.address) | ||
}) | ||
} |
1 change: 1 addition & 0 deletions
1
packages/phone-number-privacy/signer/src/common/database/models/account.ts
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
1 change: 1 addition & 0 deletions
1
packages/phone-number-privacy/signer/src/common/database/models/request.ts
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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export enum REQUESTS_TABLE { | ||
LEGACY = 'requests', | ||
ONCHAIN = 'requestsOnChain', | ||
} | ||
|
||
|