/** * @type {import('node-pg-migrate').ColumnDefinitions | undefined} */ export const shorthands = undefined; /** * @param pgm {import('node-pg-migrate').MigrationBuilder} * @param run {() => void | undefined} * @returns {Promise | void} */ export const up = (pgm) => { // Add payment provider columns to user_profiles table pgm.addColumns('user_profiles', { payment_provider_customer_id: { type: 'varchar(255)', notNull: false, comment: 'Customer ID from the payment provider (e.g., Stripe customer ID)', }, payment_provider_subscription_id: { type: 'varchar(255)', notNull: false, comment: 'Subscription ID from the payment provider (e.g., Stripe subscription ID)', }, }); // Create index for faster lookups by payment provider customer ID pgm.createIndex('user_profiles', ['payment_provider_customer_id'], { unique: false, where: 'payment_provider_customer_id IS NOT NULL', }); // Create index for faster lookups by payment provider subscription ID pgm.createIndex('user_profiles', ['payment_provider_subscription_id'], { unique: false, where: 'payment_provider_subscription_id IS NOT NULL', }); }; /** * @param pgm {import('node-pg-migrate').MigrationBuilder} * @param run {() => void | undefined} * @returns {Promise | void} */ export const down = (pgm) => { // Drop indexes first pgm.dropIndex('user_profiles', ['payment_provider_subscription_id']); pgm.dropIndex('user_profiles', ['payment_provider_customer_id']); // Drop columns pgm.dropColumns('user_profiles', [ 'payment_provider_customer_id', 'payment_provider_subscription_id', ]); };