Skip to content

Commit

Permalink
[Wallet] - Revise APIs for wallet authentication
Browse files Browse the repository at this point in the history
resolves #2403

need knex@^0.95.11 for `setNullable` `dropNullable`
knex/knex#1218 (comment)
  • Loading branch information
tx0c committed Jan 5, 2022
1 parent dab764c commit 1b8b3fc
Show file tree
Hide file tree
Showing 13 changed files with 513 additions and 3,160 deletions.
Expand Up @@ -3,7 +3,7 @@ const table = 'article_read_count'
exports.up = async (knex) => {
await knex.schema.table(table, (t) => {
t.bigInteger('timed_count').defaultTo(0)
t.timestamp('last_read').defaultTo()
t.timestamp('last_read') // .defaultTo(knex.fn.now())
})

return await knex(table).update({
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/20200604173455_add_language_to_article.js
Expand Up @@ -3,7 +3,7 @@ const column = 'language'

exports.up = (knex) =>
knex.schema.table(table, (t) => {
t.string(column).defaultTo()
t.string(column) // .defaultTo('')
})

exports.down = (knex) =>
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/20200622144415_add_remark_to_transaction.js
Expand Up @@ -3,7 +3,7 @@ const column = 'remark'

exports.up = (knex) =>
knex.schema.table(table, (t) => {
t.string(column).defaultTo()
t.string(column)
})

exports.down = (knex) =>
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/20200622163800_alter_artile_tag_creator.js
Expand Up @@ -3,7 +3,7 @@ const table = 'article_tag'
exports.up = async (knex) => {
// add creator column
await knex.schema.table(table, function (t) {
t.bigInteger('creator').unsigned().defaultTo()
t.bigInteger('creator').unsigned()
})

// update article tag creator
Expand Down
2 changes: 1 addition & 1 deletion db/migrations/20200924152926_alter_draft_as_article.js
Expand Up @@ -12,7 +12,7 @@ exports.up = async (knex) => {
t.integer('word_count')
t.string('data_hash')
t.string('media_hash')
t.string('language').defaultTo()
t.string('language')

// versioning
t.bigInteger('prev_draft_id').unsigned()
Expand Down
42 changes: 42 additions & 0 deletions db/migrations/20211231080000_alter_user_add_wallet.js
@@ -0,0 +1,42 @@
const { alterEnumString } = require('../utils')

const table = 'user'
const crypto_wallet_table = 'crypto_wallet_signature'

exports.up = async (knex) => {
await knex.schema.table(table, (t) => {
t.string('eth_address').unique()
})

await knex.schema
.raw(
alterEnumString(crypto_wallet_table, 'purpose', [
'airdrop',
'connect',
'signup',
'login',
])
)
.alterTable(crypto_wallet_table, (t) => {
// at time of generating signing message, the user_id might not be created yet
t.dropForeign('user_id')
t.setNullable('user_id')
t.string('signed_message', 1023).alter()
})
}

exports.down = async (knex) => {
await knex.schema
.alterTable(crypto_wallet_table, (t) => {
// t.enu('purpose', ['airdrop', 'connect']).alter()
t.string('signed_message', 255).alter()
t.foreign('user_id').references('id').inTable('user')
})
.raw(
alterEnumString(crypto_wallet_table, 'purpose', ['airdrop', 'connect'])
)

await knex.schema.table(table, (t) => {
t.dropColumn('eth_address')
})
}

0 comments on commit 1b8b3fc

Please sign in to comment.