Skip to content

Creating a new migration issue #8860

@adetorodev

Description

@adetorodev

Documentation Issue

After creating my entities Post. Just only one entity which is the Post.ts. I want to make migration and I got an error that does not seem clear to me. I follow the document in doing this. No migration file was created as specified by the doc.

This is my config file

import { DataSource } from "typeorm";
import { Post } from "./entities/Post";

export const pgDataSource = new DataSource({
    type: "postgres",
    host: "localhost",
    port: 5432,
    username: "postgres",
    password: "ezeka",
    database: "postMikro",
    synchronize: true,
    entities: [Post],
    migrations: [/*...*/],
    migrationsTableName: "custom_migration_table",
  });

And the index file which is my global app

import "reflect-metadata";
import { pgDataSource } from "./pgconnection";

const main = async () => {
  const DataPg = pgDataSource;

  DataPg.initialize();
};

main();

What was unclear or otherwise insufficient?

After running the migration using the command
typeorm migration:create -n PostRefactoring
I got this error:
Not enough non-option arguments: got 0, need at least 1
I also try using this command as specified in migration CLI doc
npm run typeorm migration:run
I got this error:
Missing required argument: dataSource
Lastly tried this:
npm run typeorm migration:generate -- -n postmigration
With this error:
Not enough non-option arguments: got 0, need at least 1

My question is; Is the doc unclear? Or I am missing something but I don't really think I am because I did all things according to the doc.

Recommended Fix

Additional Context

I did this with the sample project, sample32, still no migration file was created. The amazing thing was that npm start connected the app to the database. The same thing with sample1

Are you willing to resolve this issue by submitting a Pull Request?

  • ✖️ Yes, I have the time, and I know how to start.
  • ✅Yes, I have the time, but I don't know how to start. I would need guidance.
  • ✖️ No, I don’t have the time, but I can support (using donations) development.
  • ✖️ No, I don’t have the time and I’m okay to wait for the community / maintainers to resolve this issue.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions