Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Using DBIx::Class To Delete Row With Foreign Keys

by poj (Abbot)
on Jan 24, 2019 at 16:26 UTC ( [id://1228930]=note: print w/replies, xml ) Need Help??


in reply to Using DBIx::Class To Delete Row With Foreign Keys

Are there any other tables which use member.user_id and have constraints ?

poj

Replies are listed 'Best First'.
Re^2: Using DBIx::Class To Delete Row With Foreign Keys
by varanasi (Scribe) on Jan 24, 2019 at 17:20 UTC

    Yes! There is one table, Roster, that does:

    package Test::Schema::Result::Roster; . . . __PACKAGE__->add_columns( "id", { data_type => "integer", is_auto_increment => 1, is_nullable => 0}, "member_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, ); . . . __PACKAGE__->belongs_to( "member", "Test::Schema::Result::Member", { id => "member_id" }, { is_deferrable => 0, join_type => "LEFT", on_delete => "NO ACTION", on_update => "NO ACTION", }, ); ------------sql------ CREATE TABLE roster ( id INTEGER PRIMARY KEY, member_id INTEGER REFERENCES member(id) );

      In that case, delete the roster records before deleting the member.

      poj

        Well, perfect! I now understand the problem (and why I couldn't figure it out before.) I feel slightly less dumb.

        Edit: I had left some test records in roster. Sigh.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1228930]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-18 20:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found