databasedartmigrationconduit

Conduit - delete cascade tables in migration


I got some initial migration, that creates some related tables.
When I found out tables in scheme are named incorrectly, I decided to rename them like this

After that i tried to upgrade database (conduit db upgrade), but got issue that says:

C:\flutter_projects\dart_backend>dart run conduit:conduit db upgrade
Building package executable...
Built conduit:conduit.
— Conduit CLI Version: 4.1.6
— Conduit project version: 4.1.6
— Updating to version 2 from version 1...
Replaying versions: 1...
PostgreSQL connecting, postgres@localhost:5432/flutter-project.
Applying migration version 2...
CREATE TABLE authors (id BIGSERIAL PRIMARY KEY)
CREATE TABLE posts (id BIGSERIAL PRIMARY KEY,content TEXT NOT NULL)
CREATE TABLE users (id BIGSERIAL PRIMARY KEY,userName TEXT NOT NULL UNIQUE,email TEXT NOT NULL UNIQUE,password TEXT NOT NULL,accessToken TEXT NULL,refreshToken TEXT NULL)
CREATE INDEX users_userName_idx ON users (userName)
CREATE INDEX users_email_idx ON users (email)
ALTER TABLE posts ADD COLUMN author_id BIGINT NOT NULL
CREATE INDEX posts_author_id_idx ON posts (author_id)
ALTER TABLE ONLY posts ADD FOREIGN KEY (author_id) REFERENCES authors (id) ON DELETE CASCADE
DROP TABLE _Author
*** There was an issue. Reason: удалить объект таблица _author нельзÑ, так как от него завиÑÑÑ‚ другие объекты. Table: null Column: null

How can i solve this problem? Is it possible to delete tables cascade? Or can I force conduit rename instead of delete-create?


Solution

  • Solution was to edit migration and set correct order of table drops to exclude missing relations

    database.deleteTable("_User");
    database.deleteTable("_Post");
    database.deleteTable("_Author");