exports.up = (pgm) => {
  pgm.createExtension('pgcrypto', { ifNotExists: true });
  pgm.createTable('users', {
    id: { type: 'uuid', primaryKey: true, default: pgm.func('gen_random_uuid()') },
    external_subject_id: { type: 'text', notNull: true },
    display_name: { type: 'text', notNull: true },
    email: { type: 'text', notNull: true },
    created_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
    updated_at: { type: 'timestamptz', notNull: true, default: pgm.func('now()') },
  });
  pgm.addConstraint('users', 'users_external_subject_id_key', 'UNIQUE(external_subject_id)');
};

exports.down = (pgm) => {
  pgm.dropTable('users');
};
