I am getting this error while I added another field in customer schema, I want to add deactivated state and I ran npx typeorm migration:generate -d datasource.js src/migrations/customer.ts then I got this error. I am new to typeorm but I did tried adding field in product schema and I worked and the code base for of these is almost similar still getting this error I feel like it is a medusa based error. also could be that I am missing something
#Entity metadata for Customer#billing_address was not found. Check if you specified a correct entity
2 messages · Page 1 of 1 (latest)
datasource.js
const { DataSource } = require("typeorm");
const dotenv = require("dotenv");
dotenv.config()
const AppDataSource = new DataSource({
type: "postgres",
port: 5432,
port: process.env.DB_PORT,
username: process.env.DB_USER,
password: process.env.DB_PASSWORD,
database: process.env.DB_NAME,
host: process.env.DB_HOST,
entities: [
"dist/models/*.js",
],
migrations: [
"dist/migrations/*.js",
],
})
module.exports = {
datasource: AppDataSource,
}
models/customer.ts
import { Customer as BaseCustomer } from "@medusajs/medusa"
import { Column, Entity } from "typeorm"
@Entity({ name: 'customer' })
export class Customer extends BaseCustomer {
@Column({ default: false })
deactivated: boolean;
}
repository/customer.ts
import {
dataSource,
} from "@medusajs/medusa/dist/loaders/database"
import { Customer } from "../models/customer"
export const CustomerRepository = dataSource.getRepository(Customer)
export default CustomerRepository
service/customer.ts
import { ProductService as BaseProductService } from '@medusajs/medusa'
import { Customer } from '../models/customer';
import { Repository } from 'typeorm';
import CustomerRepository from '../repositories/customer';
export default class CustomerService extends BaseProductService {
protected readonly customerRepository: Repository<Customer>;
constructor(...args) {
// @ts-ignore
super(...args);
this.customerRepository = this.activeManager_.withRepository(CustomerRepository);
}
async deactivateCustomer(email: string) {
return await this.customerRepository.update({ email }, { deactivated: true });
}
}