You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Run the code once and it creates the database schema successfully.
Restart a second time (no code changes) and it errors with:
Npgsql.PostgresException: 42P16: cannot drop inherited constraint "mt_events_stream_id_is_archived_fkey" of relation "mt_events"
Full details below:
[red]ERROR:[/]Marten.Exceptions.MartenSchemaException: DDL Execution for 'All Configured Changes' Failed!
ALTER TABLE public.mt_events DROP CONSTRAINT IF EXISTS mt_events_stream_id_is_archived_fkey;
ALTER TABLE public.mt_events DROP CONSTRAINT IF EXISTS mt_events_stream_id_is_archived_fkey1;
create table public.mt_events_temp as select * from public.mt_events;
drop table public.mt_events cascade;
DROP TABLE IF EXISTS public.mt_events CASCADE;
CREATE TABLE public.mt_events (
seq_id bigint NOT NULL,
id uuid NOT NULL,
stream_id uuid NULL,
version bigint NOT NULL,
data jsonb NOT NULL,
type varchar(500) NOT NULL,
timestamp timestamp with time zone NOT NULL DEFAULT '(now())',
tenant_id varchar NULL DEFAULT '*DEFAULT*',
mt_dotnet_type varchar NULL,
is_archived bool NOT NULL DEFAULT FALSE,
CONSTRAINT pkey_mt_events_seq_id_is_archived PRIMARY KEY (seq_id, is_archived)
) PARTITION BY LIST (is_archived);
ALTER TABLE public.mt_events
ADD CONSTRAINT fkey_mt_events_stream_id_is_archived FOREIGN KEY(stream_id, is_archived)
REFERENCES public.mt_streams(id, is_archived)ON DELETE CASCADE
;
CREATE UNIQUE INDEX pk_mt_events_stream_and_version ON public.mt_events USING btree (stream_id, version, is_archived);
CREATE TABLE public.mt_events_archived partition of public.mt_events for values in (TRUE);
CREATE TABLE public.mt_events_default PARTITION OF public.mt_events DEFAULT;
insert into public.mt_events select * from public.mt_events_temp;
drop table public.mt_events_temp cascade;
Npgsql.PostgresException: 42P16: cannot drop inherited constraint "mt_events_stream_id_is_archived_fkey" of
relation "mt_events"
at async ValueTask<IBackendMessage> Npgsql.Internal.NpgsqlConnector.ReadMessageLong(bool async,
DataRowLoadingMode dataRowLoadingMode, bool readingNotifications, bool isReadingPrependedMessage)
at TResult
System.Runtime.CompilerServices.PoolingAsyncValueTaskMethodBuilder`1.StateMachineBox`1.System.Threading.Tasks.
Sources.IValueTaskSource<TResult>.GetResult(short token)
at async Task<bool> Npgsql.NpgsqlDataReader.NextResult(bool async, bool isConsuming, CancellationToken
cancellationToken)
at async Task<bool> Npgsql.NpgsqlDataReader.NextResult(bool async, bool isConsuming, CancellationToken
cancellationToken)
at async ValueTask<NpgsqlDataReader> Npgsql.NpgsqlCommand.ExecuteReader(bool async, CommandBehavior behavior,
CancellationToken cancellationToken)
at async ValueTask<NpgsqlDataReader> Npgsql.NpgsqlCommand.ExecuteReader(bool async, CommandBehavior behavior,
CancellationToken cancellationToken)
at async Task<int> Npgsql.NpgsqlCommand.ExecuteNonQuery(bool async, CancellationToken cancellationToken)
at async Task Weasel.Postgresql.PostgresqlMigrator.executeDelta(SchemaMigration migration, DbConnection conn,
AutoCreate autoCreate, IMigrationLogger logger, CancellationToken ct)
at void Marten.StoreOptions.Weasel.Core.Migrations.IMigrationLogger.OnFailure(DbCommand command, Exception ex)
at async Task Weasel.Postgresql.PostgresqlMigrator.executeDelta(SchemaMigration migration, DbConnection conn,
AutoCreate autoCreate, IMigrationLogger logger, CancellationToken ct)
at async Task<SchemaPatchDifference> Weasel.Core.Migrations.DatabaseBase`1.ApplyAllConfiguredChangesToDatabaseAsync(
IGlobalLock<TConnection> globalLock, AutoCreate? override, ReconnectionOptions reconnectionOptions,
CancellationToken ct)
at async Task<SchemaPatchDifference> Weasel.Core.Migrations.DatabaseBase`1.ApplyAllConfiguredChangesToDatabaseAsync(
IGlobalLock<TConnection> globalLock, AutoCreate? override, ReconnectionOptions reconnectionOptions,
CancellationToken ct)
at async Task Marten.Services.MartenActivator.StartAsync(CancellationToken cancellationToken)
at async Task Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)
at async Task<bool> Oakton.Commands.RunCommand.Execute(RunInput input)
at async Task<int> Oakton.CommandExecutor.execute(CommandRun run)
The text was updated successfully, but these errors were encountered:
Marten version 7.26.4
PostgreSQL: 16.4
Run the code once and it creates the database schema successfully.
Restart a second time (no code changes) and it errors with:
Npgsql.PostgresException: 42P16: cannot drop inherited constraint "mt_events_stream_id_is_archived_fkey" of relation "mt_events"
Full details below:
The text was updated successfully, but these errors were encountered: