-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
feature: fake migrations for existing tables #6195
Comments
heres a workaround i did import "reflect-metadata";
import {createConnection, MigrationExecutor} from "typeorm";
createConnection().then(async connection => {
const mig = new MigrationExecutor(connection);
await mig.showMigrations();
const migrations = await mig.getAllMigrations();
for (let migration of migrations)
{
await mig.insertMigration(migration);
}
}).catch(error => console.log(error));
|
revised version: import 'reflect-metadata';
import { createConnection, MigrationExecutor } from 'typeorm';
import config from './config';
import { join } from 'path';
createConnection({
type: 'postgres',
host: config.db.host,
port: config.db.port,
username: config.db.username,
password: config.db.password,
database: config.db.database,
entities: [join(__dirname, 'entities/*{.ts,.js}')],
logging: 'all',
migrationsTableName: 'nest_migration',
logger: 'advanced-console',
migrations: [join(__dirname, 'migrations/**/*{.ts,.js}')],
cli: {
migrationsDir: join('src', 'migrations'),
},
})
.then(async connection => {
const mig = new MigrationExecutor(connection);
await connection.manager.query(
` CREATE TABLE IF NOT EXISTS "nest_migration" ("id" SERIAL NOT NULL, "timestamp" bigint NOT NULL, "name" character varying NOT NULL, CONSTRAINT "PK_d8a054ea06850edd968e06c00e4" PRIMARY KEY ("id"))`,
);
const migrations = await mig.getAllMigrations();
console.log(migrations);
for (let migration of migrations) {
// await mig.insertMigration(migration);
await connection.manager.query(
` INSERT INTO "nest_migration"("timestamp", "name") VALUES ($1, $2) `,
[migration.timestamp, migration.name],
);
}
})
.catch(error => console.log(error)); |
@pleerock can we dosomething like this with the cli. i find it a good addition |
@rubiin was something like this feature implemented? |
Sadly no. I have to moveon to MikroOrm due to so many things |
Could you please reopen this issue then?
…On Fri, Apr 8, 2022, 00:45 Rubin Bhandari ***@***.***> wrote:
Sadly no. I have to moveon to MikroOrm due to so many things
—
Reply to this email directly, view it on GitHub
<#6195 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAESBUIYNSQ7LOPDOBHHAC3VD43MXANCNFSM4NSRZ7QQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
@rubiin willing to contribute if no one has already picked this up, please let me know. |
@ahmedosama94 You can go ahead. This issue has not been picked up. But make sure they are willing to add it first though |
Added a cli option to fake-run or fake-revert a migration, adding to the executed migrations table, but not actually running it. This feature is useful for when migrations are added after the fact or for interoperability between applications which are desired to each keep a consistent migration history Closes: typeorm#6195
Added a cli option to fake-run or fake-revert a migration, adding to the executed migrations table, but not actually running it. This feature is useful for when migrations are added after the fact or for interoperability between applications which are desired to each keep a consistent migration history Closes: typeorm#6195
Added a cli option to fake-run or fake-revert a migration, adding to the executed migrations table, but not actually running it. This feature is useful for when migrations are added after the fact or for interoperability between applications which are desired to each keep a consistent migration history Closes: typeorm#6195
Added a cli option to fake-run or fake-revert a migration, adding to the executed migrations table, but not actually running it. This feature is useful for when migrations are added after the fact or for interoperability between applications which are desired to each keep a consistent migration history Closes: typeorm#6195
* feat: add fake migrations running and reverting Added a cli option to fake-run or fake-revert a migration, adding to the executed migrations table, but not actually running it. This feature is useful for when migrations are added after the fact or for interoperability between applications which are desired to each keep a consistent migration history Closes: #6195 * changed enabled drivers in test * added docs to the property * fixed lint issue Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com> Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
* feat: add fake migrations running and reverting Added a cli option to fake-run or fake-revert a migration, adding to the executed migrations table, but not actually running it. This feature is useful for when migrations are added after the fact or for interoperability between applications which are desired to each keep a consistent migration history Closes: typeorm#6195 * changed enabled drivers in test * added docs to the property * fixed lint issue Co-authored-by: Umed Khudoiberdiev <pleerock.me@gmail.com> Co-authored-by: Dmitry Zotov <dmzt08@gmail.com>
Issue type:
[ ] question
[ ] bug report
[x] feature request
[ ] documentation issue
it would be great to fake migrations something like https://docs.djangoproject.com/en/1.11/ref/django-admin/#cmdoption-migrate-fake .
The text was updated successfully, but these errors were encountered: