Skip to content
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

Extension point needed after applying migrations programmatically #17568

Open
Tracked by #19587
roji opened this issue Sep 2, 2019 · 5 comments · Fixed by #34199
Open
Tracked by #19587

Extension point needed after applying migrations programmatically #17568

roji opened this issue Sep 2, 2019 · 5 comments · Fixed by #34199

Comments

@roji
Copy link
Member

roji commented Sep 2, 2019

Original issue: npgsql/efcore.pg#292

tl;dr PostgreSQL has extensions, which can be added via the regular migration process. However, since extensions can add database types, the ADO layer must be instructed to reload types.

EFCore.PG does this if the migration is applied when first creating a database, since RelationalDatabaseCreator is public. However, for users applying migrations programmatically (context.Database.Migrate()) this would currently require extending Migrator, which is an internal type.

This is a non-critical issue - users can work around it by triggering type reloading themselves. Npgsql can also extend Migrator for now even though it's internal.

@bricelam
Copy link
Contributor

Possibly covered by #24710

@AndriySvyryd
Copy link
Member

This can also be used for seeding.

@AndriySvyryd
Copy link
Member

The callback will be executed in a transaction, and it needs to be idempotent.

@AndriySvyryd AndriySvyryd self-assigned this Jun 20, 2024
@AndriySvyryd AndriySvyryd added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed needs-design labels Jul 10, 2024
@AndriySvyryd AndriySvyryd removed their assignment Jul 10, 2024
AndriySvyryd added a commit that referenced this issue Jul 10, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
AndriySvyryd added a commit that referenced this issue Jul 10, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
AndriySvyryd added a commit that referenced this issue Jul 10, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
AndriySvyryd added a commit that referenced this issue Jul 11, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
AndriySvyryd added a commit that referenced this issue Jul 12, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
AndriySvyryd added a commit that referenced this issue Jul 15, 2024
Allow to specify a target migration in Migrate call
Warn on Migrate when there are pending model changes

Fixes #17568
Fixes #33732
Fixes #34196
@AndriySvyryd AndriySvyryd modified the milestones: 9.0.0, Backlog Aug 9, 2024
@AndriySvyryd AndriySvyryd removed the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Aug 9, 2024
@AndriySvyryd
Copy link
Member

This was the proposed API for providers and extensions:

    public interface IMigratorPlugin
    {
        void Migrated(DbContext context, IMigratorData data);
        Task MigratedAsync(DbContext context, IMigratorData data, CancellationToken cancellationToken = default(CancellationToken));
        void Migrating(DbContext context, IMigratorData data);
        Task MigratingAsync(DbContext context, IMigratorData data, CancellationToken cancellationToken = default(CancellationToken));
    }
    public interface IMigratorData
    {
        IReadOnlyList<Migration> AppliedMigrations { get; }
        IReadOnlyList<Migration> RevertedMigrations { get; }
        Migration TargetMigration { get; }
    }

However, we decided to revisit this when we have a better understanding of the provider and extension scenarios that this will enable.

@roji
Copy link
Member Author

roji commented Aug 14, 2024

Note: this is needed in order to fix #33279

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants