Entità non si crea quando si avvia il mio progetto come si può vedere qui:
postgres-# \d emasa_base
Did not find any relation named emasa_base.
Non riesco a immaginare dove il problema è che ho un entità User:
@Entity()
export class User extends BaseEntity {
@PrimaryGeneratedColumn()
id: number;
@Column()
name: string;
@Column()
email: string;
@Column()
age: number;
@Column(timestamp)
register_at: Date;
}
le mie impostazioni 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
}
}
i miei 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();
la mia 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:
il mio file finestra mobile:
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
il mio server nodo si avvia normalmente posso accedere localhost: 4000 / graphql e anche i miei Postgres, ma per qualche ragione non viene creata la tabella Credo che il problema è nel mio file finestra mobile o il mio ORM config
sul mio log mia nodo serv:
api | �🚀 Server ready at http://localhost:4000/graphql
scorso il mio strutture di cartelle: