feat: wip Stripe connect integration

This commit is contained in:
Ahmed Bouhuolia
2024-09-09 14:18:04 +02:00
parent a183666df6
commit 162b92ce84
15 changed files with 410 additions and 4 deletions

View File

@@ -0,0 +1,20 @@
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.up = function (knex) {
return knex.schema.createTable('stripe_accounts', (table) => {
table.increments('id').primary();
table.string('stripe_account_id').notNullable();
table.string('tenant_id').notNullable();
table.timestamps(true, true); // Adds created_at and updated_at columns
});
};
/**
* @param { import("knex").Knex } knex
* @returns { Promise<void> }
*/
exports.down = function (knex) {
return knex.schema.dropTableIfExists('stripe_accounts');
};

View File

@@ -0,0 +1,49 @@
import { Model } from 'objection';
export class StripeAccount {
/**
* Table name
*/
static get tableName() {
return 'stripe_accounts';
}
/**
* Timestamps columns.
*/
get timestamps() {
return ['createdAt', 'updatedAt'];
}
/**
* Virtual attributes.
*/
static get virtualAttributes() {
return [];
}
/**
* Model modifiers.
*/
static get modifiers() {
return {};
}
/**
* Relationship mapping.
*/
static get relationMappings() {
const Tenant = require('./Tenant');
return {
tenant: {
relation: Model.BelongsToOneRelation,
modelClass: Tenant.default,
join: {
from: 'stripe_accounts.tenant_id',
to: 'tenants.id',
},
},
};
}
}

View File

@@ -7,6 +7,7 @@ import PasswordReset from './PasswordReset';
import Invite from './Invite';
import SystemPlaidItem from './SystemPlaidItem';
import { Import } from './Import';
import { StripeAccount } from './StripeAccount';
export {
Plan,
@@ -18,4 +19,5 @@ export {
Invite,
SystemPlaidItem,
Import,
StripeAccount
};