diff --git a/core/server/data/exporter/index.js b/core/server/data/exporter/index.js index 8954c650c4..5448191b77 100644 --- a/core/server/data/exporter/index.js +++ b/core/server/data/exporter/index.js @@ -33,6 +33,8 @@ const BACKUP_TABLES = [ 'snippets', 'tokens', 'sessions', + 'stripe_products', + 'stripe_prices', 'mobiledoc_revisions', 'email_batches', 'email_recipients', diff --git a/core/server/data/migrations/versions/4.3/05-add-stripe-products-table.js b/core/server/data/migrations/versions/4.3/05-add-stripe-products-table.js new file mode 100644 index 0000000000..7458a2cb16 --- /dev/null +++ b/core/server/data/migrations/versions/4.3/05-add-stripe-products-table.js @@ -0,0 +1,9 @@ +const {addTable} = require('../../utils'); + +module.exports = addTable('stripe_products', { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + product_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'products.id'}, + stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: true}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} +}); diff --git a/core/server/data/migrations/versions/4.3/06-add-stripe-prices-table.js b/core/server/data/migrations/versions/4.3/06-add-stripe-prices-table.js new file mode 100644 index 0000000000..3aee0754c7 --- /dev/null +++ b/core/server/data/migrations/versions/4.3/06-add-stripe-prices-table.js @@ -0,0 +1,16 @@ +const {addTable} = require('../../utils'); + +module.exports = addTable('stripe_prices', { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true}, + stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id'}, + active: {type: 'boolean', nullable: false}, + livemode: {type: 'boolean', nullable: false}, + nickname: {type: 'string', maxlength: 50, nullable: true}, + currency: {type: 'string', maxLength: 3, nullable: false}, + amount: {type: 'integer', nullable: false}, + type: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'recurring', validations: {isIn: [['recurring', 'one_time']]}}, + interval: {type: 'string', maxlength: 50, nullable: false}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} +}); diff --git a/core/server/data/schema/schema.js b/core/server/data/schema/schema.js index cf8bc0ab5f..a23586b3b0 100644 --- a/core/server/data/schema/schema.js +++ b/core/server/data/schema/schema.js @@ -475,6 +475,27 @@ module.exports = { created_at: {type: 'dateTime', nullable: false}, source: {type: 'string', maxlength: 50, nullable: true} }, + stripe_products: { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + product_id: {type: 'string', maxlength: 24, nullable: false, unique: false, references: 'products.id'}, + stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: true}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} + }, + stripe_prices: { + id: {type: 'string', maxlength: 24, nullable: false, primary: true}, + stripe_price_id: {type: 'string', maxlength: 255, nullable: false, unique: true}, + stripe_product_id: {type: 'string', maxlength: 255, nullable: false, unique: false, references: 'stripe_products.stripe_product_id'}, + active: {type: 'boolean', nullable: false}, + livemode: {type: 'boolean', nullable: false}, + nickname: {type: 'string', maxlength: 50, nullable: true}, + currency: {type: 'string', maxLength: 3, nullable: false}, + amount: {type: 'integer', nullable: false}, + type: {type: 'string', maxlength: 50, nullable: false, defaultTo: 'recurring', validations: {isIn: [['recurring', 'one_time']]}}, + interval: {type: 'string', maxlength: 50, nullable: false}, + created_at: {type: 'dateTime', nullable: false}, + updated_at: {type: 'dateTime', nullable: true} + }, actions: { id: {type: 'string', maxlength: 24, nullable: false, primary: true}, resource_id: {type: 'string', maxlength: 24, nullable: true}, diff --git a/test/regression/exporter/exporter_spec.js b/test/regression/exporter/exporter_spec.js index 4153cc679a..86b5d36260 100644 --- a/test/regression/exporter/exporter_spec.js +++ b/test/regression/exporter/exporter_spec.js @@ -53,6 +53,8 @@ describe('Exporter', function () { 'posts_meta', 'posts_tags', 'products', + 'stripe_products', + 'stripe_prices', 'roles', 'roles_users', 'sessions', diff --git a/test/unit/data/schema/integrity_spec.js b/test/unit/data/schema/integrity_spec.js index 3fada51347..fe162f9c9d 100644 --- a/test/unit/data/schema/integrity_spec.js +++ b/test/unit/data/schema/integrity_spec.js @@ -32,7 +32,7 @@ const defaultSettings = require('../../../../core/server/data/schema/default-set */ describe('DB version integrity', function () { // Only these variables should need updating - const currentSchemaHash = '9d62f0a673a4f02af8a980495793ac4f'; + const currentSchemaHash = 'a507f692edce7d13d1b75c124b3a30b7'; const currentFixturesHash = '779f29a247161414025637e10e99a278'; const currentSettingsHash = '7ac732b994a5bb1565f88c8a84872964'; const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';