Entidad no se crea al iniciar mi proyecto como se puede ver aquí:
postgres-# \d emasa_base
Did not find any relation named emasa_base.
No me puedo imaginar donde el problema es que tengo una entidad Usuario:
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
email: string;
@Column()
age: number;
@Column(timestamp)
register_at: Date;
}
mi configuración tpyeorm ormconfig :
{
type: postgres,
host: db,
port: 5432,
username: spirit,
password: emasa,
database: emasa_base,
synchronize: true,
logging: false,
entities: [src/entity/**/*.ts],
migrations: [src/migration/**/*.ts],
subscribers: [src/subscriber/**/*.ts],
cli: {
entitiesDir: src/entity,
migrationsDir: src/migration,
subscribersDir: src/subscriber
}
}
mis index.ts
const startServer = async () => {
const server = new ApolloServer({
schema,
context: ({ req, res }: any) => ({ req, res })
});
let retries = 5;
while (retries) {
try {
await createConnection();
break;
} catch (err) {
console.log(err);
retries -= 1;
console.log(`retries left: ${retries}`);
await new Promise(res => setTimeout(res, 5000));
}
}
const app = express();
server.applyMiddleware({ app });
app.listen({ port: process.env.SERVER_PORT }, () =>
console.log(`🚀 Server ready at http://localhost:4000${server.graphqlPath}`)
);
};
startServer();
mi dockercompose:
version: 3.7
services:
db:
image: postgres:12
restart: always
container_name: db
ports:
- ${DB_PORT}:5432
volumes:
- db_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: ${DB_USER}
POSTGRES_PASSWORD: ${DB_PASS}
POSTGRES_DB: ${DB_NAME}
pgadmin:
image: dpage/pgadmin4
restart: always
container_name: pgadmin4
depends_on:
- db
ports:
- 5050:80
environment:
PGADMIN_DEFAULT_EMAIL: emasa@emasa.com
PGADMIN_DEFAULT_PASSWORD: admin
api:
image: server_emasa
container_name: api
restart: always
depends_on:
- db
ports:
- ${SERVER_PORT}:${SERVER_PORT}
volumes:
db_data:
mi archivo de cargador de muelle:
FROM node as builder
WORKDIR usr/app
COPY package*.json ./
RUN yarn install
COPY . .
RUN yarn run build
FROM node
WORKDIR usr/app
COPY package*.json ./
RUN yarn install --production
COPY --from=builder /usr/app/dist ./dist
COPY ormconfig.docker.json ./ormconfig.json
COPY .env .
expose 4000
CMD node dist/src/index.js
mi servidor de nodo se inicia normalmente puedo acceder a localhost: 4000 / graphql y también mis postgres, pero por alguna razón no se está creando la tabla Creo que el problema está en mi archivo de cargador de muelle o de mi config ORM
en mis registros de mi nodo de serv:
api | �🚀 Server ready at http://localhost:4000/graphql
duran las estructuras de carpetas: