Skip to content

Commit

Permalink
feat: switch to UUID for all primary keys
Browse files Browse the repository at this point in the history
  • Loading branch information
ZavenArra committed Feb 11, 2021
1 parent cb9a65d commit 5bd9606
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 31 deletions.
24 changes: 1 addition & 23 deletions database/migrations/20200826045033-CreateTableTransaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,10 @@ exports.setup = function(options, seedLink) {

exports.up = function (db) {
return db.createTable('transaction', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
token_id: {
type: 'int',
notNull: true,
// foreignKey: {
// name: 'transaction_token_id_fk',
// table: 'token',
// mapping: {
// token_id: 'id'
// },
// rules: {
// onDelete: 'CASCADE',
// onUpdate: 'RESTRICT',
// },
// },
},
transfer_id: { type: 'int', notNull: true },
source_entity_id: { type: 'int', notNull: true },
Expand All @@ -41,17 +30,6 @@ exports.up = function (db) {
defaultValue: new String('now()')
},
})
// .then(
// () => {
// db.addForeignKey('transaction', 'token', 'transaction_token_id_fk',
// {
// 'token_id': 'id',
// },
// {
// onDelete: 'CASCADE',
// onUpdate: 'RESTRICT',
// });
// });
};

exports.down = function (db) {
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/20200901213253-CreateTableToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function (db) {
return db.createTable('token', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
tree_id: { type: 'int', notNull: true },
entity_id: { type: 'int', notNull: true },
uuid: {
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/20200901213254-CreateTableTransfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function (db) {
return db.createTable('transfer', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
originator_entity_id: { type: 'int', notNull: true },
source_entity_id: { type: 'int', notNull: true },
destination_entity_id: { type: 'int', notNull: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function(db) {
return db.createTable('wallet_event', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
entity_id: { type: 'int', notNull: true },
type: { type: 'wallet_event_type', notNull: true },
created_at: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function(db) {
return db.createTable('entity_trust', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
actor_entity_id: { type: 'int' },
target_entity_id: { type: 'int', notNull: true },
type: { type: 'entity_trust_type' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function(db) {
return db.createTable('entity_trust_log', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
entity_trust_id: { type: 'int', notNull: true },
actor_entity_id: { type: 'int', notNull: true },
target_entity_id: { type: 'int', notNull: true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function(db) {
return db.createTable('transfer_audit', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
transfer_id: { type: 'int', notNull: true },
new_state: { type: 'transfer_state', notNull: true },
processed_at: {
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/20200916235257-CreateTableApi-Key.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.setup = function(options, seedLink) {

exports.up = function(db) {
return db.createTable('api_key', {
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
key: { type: 'string' },
tree_token_api_access: { type: 'boolean' },
hash: { type: 'string' },
Expand Down
2 changes: 1 addition & 1 deletion database/migrations/20200917183542-CreateTableWallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ exports.setup = function(options, seedLink) {
exports.up = function(db) {
return db.createTable('wallet', {
// primary key references foreign keys on payment, token, transaction, trees, planter, entity_role, and entity_manager(?) tables
id: { type: 'int', primaryKey: true, autoIncrement: true },
id: { type: 'uuid', primaryKey: true },
type: { type: 'string' },
// this wallet name points to the wallet column in entity
name: { type: 'string', notNull: true },
Expand Down

0 comments on commit 5bd9606

Please sign in to comment.