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

UI Storage providers - Tables custom prefix #481

Open
CarlosLanderas opened this issue Apr 15, 2020 · 14 comments
Open

UI Storage providers - Tables custom prefix #481

CarlosLanderas opened this issue Apr 15, 2020 · 14 comments
Labels
enhancement New feature or request question Further information is requested

Comments

@CarlosLanderas
Copy link
Contributor

CarlosLanderas commented Apr 15, 2020

I would like to throw a question for those users that are planning to use the new storage providers.

All storage packages run migrations by default against the database configured in the connection string and like tables before where created internally in sqlite it wasn't necessary to use table prefixes.

If someone wants to run migrations in a database that already has tables, it could be interesting being able to configure a prefix so instead of having a table called Configurations you could prefix it like Healthchecks_Configurations or UI_Configurations (whatever)

What do you think about this idea? Is something you might want/need to have in the public API surface?

Thanks!

@CarlosLanderas CarlosLanderas added the question Further information is requested label Apr 15, 2020
@CarlosLanderas CarlosLanderas changed the title Storage providers - Tables custom prefix UI Storage providers - Tables custom prefix Apr 15, 2020
@CarlosLanderas CarlosLanderas added the enhancement New feature or request label Apr 15, 2020
@OskarKlintrot
Copy link

If I remember correct, Hangfire uses it's own schema. Would that work here as well?

@IeuanWalker
Copy link

IeuanWalker commented Jul 24, 2020

@CarlosLanderas I like this idea would also be good to set the table schema, like @OskarKlintrot mentioned, hangfire does this -
image

Could probably see how it's done in there repo - https://github.com/HangfireIO/Hangfire/search?q=DefaultSchema&unscoped_q=DefaultSchema

@rj-digimuth
Copy link

Yes please. I was very confused when it created seemingly random tables, only two of which are prefixed with HealthCheck (which adds even more chaos). I had to find migration file in this repo to find out which tables to check/clear.

Simple prefix would be enough for me, e.g. HealthCheck_Failures, but custom schema (like HangFire presented in the comment above) would be the best.

Ultimate solution is to move table names and schema to configuration, but that's not so important.

@CarlosLanderas
Copy link
Contributor Author

CarlosLanderas commented Dec 6, 2020

Hello!. I think this is a important feature too, that's why I opened this thread. I'm currently implementing the ability to configure a custom schema.

This will be included in 5.0.0 (not preview)

cc @unaizorrilla

Sample usage:

.AddSqlServerStorage(cnnString, hcContextOptions => {
                    hcContextOptions.UseSchema("health");
                    //Migrations options removed from UI options and added in provider options
                    //hcContextOptions .DisableMigrations(true);
                });

@camiteca
Copy link

I've updated to 5.0.1 and the method isn't there. This is related to #647.

@erikrenaud
Copy link

Yes, the ability to set the schema would be great, as well as being able to set the migrations history table name and schema.

Ideally, the ability to work work with an outside DBContext.

I really like the way OpenIDDict does it by just having a .AddOpenIdDictEntities().
my code looks like this :


  public class OIDCContext : DbContext
  {
    public OIDCContext(DbContextOptions<OIDCContext> options, IConfiguration configuration) : base(options)
    {
    }

    protected override void OnModelCreating(ModelBuilder builder)
    {
      base.OnModelCreating(builder);
      builder.HasDefaultSchema("OIDC");
    }
  }

      services.AddDbContext<OIDCContext>(options =>
        {
          var connectionString = configuration.GetConnectionString("SQL");
          options.UseSqlServer(connectionString, o =>
                  {
                    o.EnableRetryOnFailure();
                    o.MigrationsHistoryTable("__Migrations", "OIDC");
                  });
          options.UseOpenIddict();
        });

The way AspNetCore does it is also interesting by having an interface with DbSet to be added to any DbContext.

My apps always have multiple dbcontexts for different domains and i have a bit of code that allows you to run the migrations for all of them, or run in a drop-create mode where i run the the generatedSQL for each context on an empty database.

@unchase
Copy link

unchase commented Aug 20, 2021

Hi, @CarlosLanderas

Are you planning to add this feature soon?

@camedool
Copy link

camedool commented Dec 9, 2021

Hi @CarlosLanderas ,

Is it still planned to add extension for custom schema setup?
Thanks!

@HeardsTheWord
Copy link

HeardsTheWord commented Feb 2, 2023

I am on 6.0.5, and I do not see the ability to update the schema for all SqlServer.Storage tables. I can change the MigrationsHistory table, but that appears to be the only table that can be updated.

.AddSqlServerStorage(connectionString, configureOptions =>
            {
                configureOptions.UseSqlServer(serverOptions =>
                {
                    serverOptions.MigrationsHistoryTable("HealthChecksMigrationHistory", schema: "HealthChecks");
                });
            });

@CarlosLanderas Is still still a planned feature for all of the tables?

@NinjaCross
Copy link

NinjaCross commented May 2, 2023

Hi @CarlosLanderas !
Any news about this ?

@sungam3r
Copy link
Collaborator

sungam3r commented Jul 5, 2023

fixed in #1858

@sungam3r sungam3r closed this as completed Jul 5, 2023
@MelGrubb
Copy link

MelGrubb commented Aug 14, 2023

I could be missing something here, but I don't see how #1858 addresses the original issue. I still don't see how we can change the table prefix or set a custom schema. So far, I only see an option to change the history table name/schema, but none of the others. Is there documentation somewhere for the new functionality? I'm not finding it by poking around with Intellisense, that's for sure.

@sungam3r sungam3r reopened this Dec 3, 2023
@DexMRS
Copy link

DexMRS commented Feb 17, 2024

Any updates?

@sungam3r
Copy link
Collaborator

Unfortunately no. I remember about that issue and track all activity in repo but I'm very limited in time to support project. I hope to return here some time later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests