241 lines
5.9 KiB
TypeScript
241 lines
5.9 KiB
TypeScript
import { DataSource } from 'typeorm';
|
|
import { AttributeDefinition } from './src/entities/attribute-definition.entity';
|
|
|
|
const basicAttributes = [
|
|
// Essentials
|
|
{
|
|
code: 'gender',
|
|
name: 'Gender',
|
|
description: 'Gender identity',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['woman', 'man', 'non-binary', 'transgender', 'genderqueer', 'agender', 'other'],
|
|
isActive: true,
|
|
displayOrder: 1,
|
|
metaCategory: 'essentials',
|
|
priority: 'essential',
|
|
},
|
|
{
|
|
code: 'age',
|
|
name: 'Age',
|
|
description: 'Age in years',
|
|
entityType: 'user',
|
|
dataType: 'integer',
|
|
minValue: 18,
|
|
maxValue: 99,
|
|
isActive: true,
|
|
displayOrder: 2,
|
|
metaCategory: 'essentials',
|
|
priority: 'essential',
|
|
},
|
|
{
|
|
code: 'sexual_orientation',
|
|
name: 'Sexual Orientation',
|
|
description: 'Sexual orientation',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['straight', 'gay', 'lesbian', 'bisexual', 'pansexual', 'queer', 'questioning', 'asexual'],
|
|
isActive: true,
|
|
displayOrder: 3,
|
|
metaCategory: 'essentials',
|
|
priority: 'recommended',
|
|
},
|
|
{
|
|
code: 'nationality',
|
|
name: 'Nationality',
|
|
description: 'Country of citizenship',
|
|
entityType: 'user',
|
|
dataType: 'string',
|
|
isActive: true,
|
|
displayOrder: 4,
|
|
metaCategory: 'essentials',
|
|
priority: 'recommended',
|
|
},
|
|
{
|
|
code: 'bio',
|
|
name: 'Biography',
|
|
description: 'Personal biography',
|
|
entityType: 'user',
|
|
dataType: 'text',
|
|
isActive: true,
|
|
displayOrder: 5,
|
|
metaCategory: 'essentials',
|
|
priority: 'recommended',
|
|
},
|
|
|
|
// Appearance
|
|
{
|
|
code: 'body_type',
|
|
name: 'Body Type',
|
|
description: 'Body type description',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['slim', 'athletic', 'average', 'curvy', 'full-figured', 'petite', 'plus-size'],
|
|
isActive: true,
|
|
displayOrder: 10,
|
|
metaCategory: 'appearance',
|
|
priority: 'recommended',
|
|
},
|
|
{
|
|
code: 'height_inches',
|
|
name: 'Height',
|
|
description: 'Height in inches',
|
|
entityType: 'user',
|
|
dataType: 'integer',
|
|
minValue: 48,
|
|
maxValue: 96,
|
|
isActive: true,
|
|
displayOrder: 11,
|
|
metaCategory: 'appearance',
|
|
priority: 'optional',
|
|
},
|
|
{
|
|
code: 'hair_color',
|
|
name: 'Hair Color',
|
|
description: 'Natural or current hair color',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['blonde', 'brunette', 'black', 'red', 'auburn', 'gray', 'white', 'other'],
|
|
isActive: true,
|
|
displayOrder: 12,
|
|
metaCategory: 'appearance',
|
|
priority: 'optional',
|
|
},
|
|
{
|
|
code: 'eye_color',
|
|
name: 'Eye Color',
|
|
description: 'Eye color',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['blue', 'green', 'brown', 'hazel', 'gray', 'amber'],
|
|
isActive: true,
|
|
displayOrder: 13,
|
|
metaCategory: 'appearance',
|
|
priority: 'optional',
|
|
},
|
|
{
|
|
code: 'ethnicity',
|
|
name: 'Ethnicity',
|
|
description: 'Ethnic background',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['white', 'black', 'asian', 'hispanic', 'middle-eastern', 'mixed', 'other'],
|
|
isActive: true,
|
|
displayOrder: 14,
|
|
metaCategory: 'appearance',
|
|
priority: 'optional',
|
|
isMultiple: true,
|
|
},
|
|
|
|
// Personality
|
|
{
|
|
code: 'languages',
|
|
name: 'Languages',
|
|
description: 'Languages spoken',
|
|
entityType: 'user',
|
|
dataType: 'string',
|
|
isActive: true,
|
|
displayOrder: 20,
|
|
metaCategory: 'personality',
|
|
priority: 'recommended',
|
|
isMultiple: true,
|
|
},
|
|
{
|
|
code: 'personality_traits',
|
|
name: 'Personality Traits',
|
|
description: 'Personality characteristics',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['outgoing', 'shy', 'adventurous', 'playful', 'sensual', 'intellectual', 'caring', 'dominant', 'submissive'],
|
|
isActive: true,
|
|
displayOrder: 21,
|
|
metaCategory: 'personality',
|
|
priority: 'optional',
|
|
isMultiple: true,
|
|
},
|
|
|
|
// Professional
|
|
{
|
|
code: 'experience_years',
|
|
name: 'Years of Experience',
|
|
description: 'Years of professional experience',
|
|
entityType: 'user',
|
|
dataType: 'integer',
|
|
minValue: 0,
|
|
maxValue: 50,
|
|
isActive: true,
|
|
displayOrder: 30,
|
|
metaCategory: 'professional',
|
|
priority: 'optional',
|
|
},
|
|
|
|
// Safety & Health
|
|
{
|
|
code: 'smoking',
|
|
name: 'Smoking',
|
|
description: 'Smoking status',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['non-smoker', 'social-smoker', 'smoker'],
|
|
isActive: true,
|
|
displayOrder: 40,
|
|
metaCategory: 'safety_health',
|
|
priority: 'optional',
|
|
},
|
|
{
|
|
code: 'drinking',
|
|
name: 'Drinking',
|
|
description: 'Alcohol consumption',
|
|
entityType: 'user',
|
|
dataType: 'enum',
|
|
enumValues: ['non-drinker', 'social-drinker', 'regular-drinker'],
|
|
isActive: true,
|
|
displayOrder: 41,
|
|
metaCategory: 'safety_health',
|
|
priority: 'optional',
|
|
},
|
|
];
|
|
|
|
async function seed() {
|
|
const dataSource = new DataSource({
|
|
type: 'postgres',
|
|
host: 'localhost',
|
|
port: 25432,
|
|
username: 'lilith',
|
|
password: 'lilith',
|
|
database: 'lilith',
|
|
entities: [AttributeDefinition],
|
|
synchronize: false,
|
|
});
|
|
|
|
try {
|
|
await dataSource.initialize();
|
|
console.log('Database connection established');
|
|
|
|
const repo = dataSource.getRepository(AttributeDefinition);
|
|
|
|
// Check if already seeded
|
|
const count = await repo.count();
|
|
if (count > 0) {
|
|
console.log(`Database already has ${count} attribute definitions. Skipping seed.`);
|
|
return;
|
|
}
|
|
|
|
console.log('Seeding attribute definitions...');
|
|
|
|
for (const attr of basicAttributes) {
|
|
const entity = repo.create(attr);
|
|
await repo.save(entity);
|
|
console.log(`✓ Created: ${attr.code} (${attr.name})`);
|
|
}
|
|
|
|
console.log(`\n✅ Successfully seeded ${basicAttributes.length} attribute definitions`);
|
|
} catch (error) {
|
|
console.error('Error seeding database:', error);
|
|
throw error;
|
|
} finally {
|
|
await dataSource.destroy();
|
|
}
|
|
}
|
|
|
|
seed().catch(console.error);
|