From f1cbb265bd3e96aed5b14d0dd484f719beb35529 Mon Sep 17 00:00:00 2001 From: Ruud Date: Sun, 15 Apr 2012 23:17:38 +0200 Subject: [PATCH] Cascaded deletion --- couchpotato/core/settings/model.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/couchpotato/core/settings/model.py b/couchpotato/core/settings/model.py index 4dd54d32..bcf5adb8 100644 --- a/couchpotato/core/settings/model.py +++ b/couchpotato/core/settings/model.py @@ -44,8 +44,8 @@ class Movie(Entity): library = ManyToOne('Library') status = ManyToOne('Status') profile = ManyToOne('Profile') - releases = OneToMany('Release') - files = ManyToMany('File') + releases = OneToMany('Release', cascade = 'all, delete-orphan') + files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) class Library(Entity): @@ -59,9 +59,9 @@ class Library(Entity): info = Field(JsonType) status = ManyToOne('Status') - movies = OneToMany('Movie') - titles = OneToMany('LibraryTitle') - files = ManyToMany('File') + movies = OneToMany('Movie', cascade = 'all, delete-orphan') + titles = OneToMany('LibraryTitle', cascade = 'all, delete-orphan') + files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) class LibraryTitle(Entity): @@ -94,9 +94,9 @@ class Release(Entity): movie = ManyToOne('Movie') status = ManyToOne('Status') quality = ManyToOne('Quality') - files = ManyToMany('File') - history = OneToMany('History') - info = OneToMany('ReleaseInfo') + files = ManyToMany('File', cascade = 'all, delete-orphan', single_parent = True) + history = OneToMany('History', cascade = 'all, delete-orphan') + info = OneToMany('ReleaseInfo', cascade = 'all, delete-orphan') class ReleaseInfo(Entity): @@ -229,6 +229,12 @@ class Folder(Entity): label = Field(Unicode(255)) +class Properties(Entity): + + identifier = Field(String(50), index = True) + value = Field(Unicode(255), nullable = False) + + def setup(): """Setup the database and create the tables that don't exists yet""" from elixir import setup_all, create_all