Skip to content
This repository has been archived by the owner on Jul 17, 2020. It is now read-only.

Permission denied to create extension "adminpack". #90

Open
asynts opened this issue Apr 14, 2020 · 2 comments
Open

Permission denied to create extension "adminpack". #90

asynts opened this issue Apr 14, 2020 · 2 comments

Comments

@asynts
Copy link
Contributor

asynts commented Apr 14, 2020

I am not sure when this was introduced but the build is currently broken:

$ cd src/WebApp && dotnet run
fail: Microsoft.EntityFrameworkCore.Database.Command[20102]
      Failed executing DbCommand (2ms) [Parameters=[], CommandType='Text', CommandTimeout='30']
      CREATE TYPE audit.history_activity_type AS ENUM ('CREATE', 'UPDATE_BEFORE', 'UPDATE_AFTER', 'DELETE');
      CREATE TYPE post_type AS ENUM ('question', 'answer', 'blog');
      CREATE EXTENSION IF NOT EXISTS adminpack;
fail: Codidact.Core.WebApp.Startup[0]
      Unable to apply database migrations. Check the connection string in your appsettings file.
crit: Microsoft.AspNetCore.Hosting.Diagnostics[6]
      Application startup exception
Npgsql.PostgresException (0x80004005): 42501: permission denied to create extension "adminpack"
   at Codidact.Core.WebApp.Startup.ApplyDatabaseMigrations(IApplicationBuilder app, ILogger logger) in /home/me/dev/codidact/core/src/WebApp/Startup.cs:line 163
   at Codidact.Core.WebApp.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger`1 logger) in /home/me/dev/codidact/core/src/WebApp/Startup.cs:line 140
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__2(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
  Exception data:
    Severity: ERROR
    SqlState: 42501
    MessageText: permission denied to create extension "adminpack"
    Hint: Must be superuser to create this extension.
    File: extension.c
    Line: 806
    Routine: execute_extension_script
Unhandled exception. Npgsql.PostgresException (0x80004005): 42501: permission denied to create extension "adminpack"
   at Codidact.Core.WebApp.Startup.ApplyDatabaseMigrations(IApplicationBuilder app, ILogger logger) in /home/me/dev/codidact/core/src/WebApp/Startup.cs:line 163
   at Codidact.Core.WebApp.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger`1 logger) in /home/me/dev/codidact/core/src/WebApp/Startup.cs:line 140
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.ConfigureBuilder.<>c__DisplayClass4_0.<Build>b__0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<>c__DisplayClass13_0.<UseStartup>b__2(IApplicationBuilder app)
   at Microsoft.AspNetCore.Mvc.Filters.MiddlewareFilterBuilderStartupFilter.<>c__DisplayClass0_0.<Configure>g__MiddlewareFilterBuilder|0(IApplicationBuilder builder)
   at Microsoft.AspNetCore.HostFilteringStartupFilter.<>c__DisplayClass0_0.<Configure>b__0(IApplicationBuilder app)
   at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)
   at Codidact.Core.WebApp.Program.Main(String[] args) in /home/me/dev/codidact/core/src/WebApp/Program.cs:line 13
   at Codidact.Core.WebApp.Program.<Main>(String[] args)
  Exception data:
    Severity: ERROR
    SqlState: 42501
    MessageText: permission denied to create extension "adminpack"
    Hint: Must be superuser to create this extension.
    File: extension.c
    Line: 806
    Routine: execute_extension_script

I remember having a discussion somewhere, that some of the generated code referenced the "adminpack" extension somewhere. It is mentioned in some of the database migrations.

We should remove this from the migrations and find the cause of this issue.

@misha130
Copy link
Contributor

This one:

.HasPostgresExtension("adminpack");

@asynts
Copy link
Contributor Author

asynts commented Apr 15, 2020

I tried removing that but that was not enough, still the same issue. I got it running by doing grep -r adminpack (Linux) and removing everything that had the word "adminpack" in it.

After removing it from the migrations it somehow worked, but I was very confused why this made a difference. If Entity Framework is presented with an empty database, it uses the dbcontext snapshot to initialize it, right? But removing it from there was not enough...

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

No branches or pull requests

2 participants