-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migration:generate: No changes in database schema were found #5965
Comments
Generating migrations compare your current database with your schema So if your database it already in the desired state, no migrations will be generated |
Hi @mastilver, thanks for you answer, but the problem is that there are changes in my entities that need to be synced with the database. Those changes are being detected by |
Run |
The same problem! schema:log says me that my schema is up to date but my database is empty. There is no any table. |
I'm encountering this issue as well for postgres! @diogodomanski did you manage to fix this? |
Im having the same issue. How to fix this ! |
I think I am not the only one to have this problem. :D |
Turns out my postgres database was storing the migrations in a pgdata folder |
Faced with same error and fixed it. I'm using ormconfig.env configuration and I had a coma ',' inside TYPEORM_ENTITIES variable it looked like: TYPEORM_ENTITIES='./apps/**/*.entity{.ts,.js}' This variable must turn to array in JS, thus there is function that splits string by coma
After I set variable as below, issue was fixed: TYPEORM_ENTITIES='./apps/**/*.entity.ts' |
I have a similar problem. In my ormconfig.js: {
entities: [
"src/entity/**/*.{.ts,.js}"
],
migrations: [
"src/migration/**/*.{.ts,.js}"
],
cli: {
"entitiesDir": "src/entity",
"migrationsDir": "src/migration",
"subscribersDir": "src/subscriber"
},
} packege.json: "scripts": {
[...]
"typeorm": "node --require ts-node/register ./node_modules/typeorm/cli.js"
}, I have empty database (and some entities classes), but after I'm also using docker with posgres and I've deleted data folder as @mezeru said, but nothing changed. |
In my case was just missed TYPEORM_ENTITIES=src/db/models/entities/*.ts .env constant |
i can solve this runnin: and try again |
This worked for me, i still don't know why |
it was giving the same error but it worked with this structure: my data-source.ts file: import "reflect-metadata";
import { config } from "dotenv";
import { DataSource } from "typeorm";
import { join } from "path";
config();
export const AppDataSource = new DataSource({
type: "postgres",
url: process.env.DB_URI_DEV,
ssl:
process.env.NODE_ENV === "production"
? { rejectUnauthorized: false }
: false,
synchronize: false,
logging: true,
entities:
process.env.NODE_ENV === "production"
? ["dist/entities/**/*.js"]
: [join(__dirname, "./entities/**/*.ts")],
migrations:
process.env.NODE_ENV === "production"
? ["dist/migrations/**/*.js"]
: [join(__dirname, "./migrations/**/*.ts")],
}); my server.ts file: import { config } from "dotenv";
import app from "./app";
import { AppDataSource } from "./data-source";
config();
AppDataSource.initialize()
.then(() => {
console.log("Data Source initialized");
const port = process.env.PORT ?? 3000;
app.listen(port, () =>
console.log(`App running!\nhttp://localhost:${port}/`)
);
})
.catch((error) =>
console.log("Error during Data Source initialization", error)
); my app.ts file: import "express-async-errors";
import express from "express";
import { errorHandling } from "./errors";
import registerRoutes from "./routes";
const app = express();
app.use(express.json());
registerRoutes(app);
app.use(errorHandling);
export default app; My error was in the entities path in the data-source.ts file. |
Can confirm this in datasource config // ...
entities:
process.env.NODE_ENV === "production"
? ["dist/entities/**/*.js"]
: [join(__dirname, "./entities/**/*.ts")],
migrations:
process.env.NODE_ENV === "production"
? ["dist/migrations/**/*.js"]
: [join(__dirname, "./migrations/**/*.ts")], works with/without running npm run build. |
Did you manage to solve it? same problem here |
this works for me. after scratching my head for hours and deleting everything |
thanks janu its works for me but i don't know why |
I have a similar problem. |
Issue type:
[x] question
[ ] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ]
cordova
[ ]
mongodb
[ ]
mssql
[x]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
cockroachdb
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
[ ]
expo
TypeORM version:
[ ]
latest
[ ]
@next
[x]
0.2.24
I'm am developing an application using NestJS and TypeORM. Whenever I try to generate migrations from my entities (by running
typeorm migration:generate
) I get the following message:I even deleted all the existing migration files (from migrations folder) to exclude any possibility of conflict.
The problem begun after I changed my application's modules folders structure to:
As can be seen, the
migrations
folder is right undersrc
and each module has anentity
folder, where the entities for that module are placed. All the ormconfig settings come fromcli-configuration.ts
file.In
package.json
file I added the following toscripts
:The content of
src/config/database/mysql/cli-configuration.ts
file is:Running
console.log(config)
I get:Last but not least.... After spending hours on this issue (making changes to migrations and entities paths, hard-coding values besides getting them from process.env, etc), I tried to execute
yarn run typeorm schema:log
(npm run
works as well). I got surprised when I saw that all the content that I expected to be in the migration file I am trying to generate was output to console.Can anyone tell me why is
schema:log
detecting the changes in my entities, butmigration:generate
is not working?The text was updated successfully, but these errors were encountered: