my %kivitendo_package_names = (
# TABLE # MODEL (given in C style)
acc_trans => 'acc_transaction',
- audittrail => 'audit_trail',
'auth.clients' => 'auth_client',
'auth.clients_users' => 'auth_client_user',
'auth.clients_groups' => 'auth_client_group',
+++ /dev/null
-# This file has been auto-generated. Do not modify it; it will be overwritten
-# by rose_auto_create_model.pl automatically.
-package SL::DB::AuditTrail;
-
-use strict;
-
-use base qw(SL::DB::Object);
-
-__PACKAGE__->meta->table('audittrail');
-
-__PACKAGE__->meta->columns(
- action => { type => 'text' },
- employee_id => { type => 'integer' },
- formname => { type => 'text' },
- id => { type => 'serial', not_null => 1 },
- reference => { type => 'text' },
- tablename => { type => 'text' },
- trans_id => { type => 'integer' },
- transdate => { type => 'timestamp', default => 'now' },
-);
-
-__PACKAGE__->meta->primary_key_columns([ 'id' ]);
-
-1;
-;
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
+
+ salesman => {
+ class => 'SL::DB::Employee',
+ key_columns => { salesman_id => 'id' },
+ },
);
1;
ar_show_mark_as_paid => { type => 'boolean', default => 'true' },
articlenumber => { type => 'text' },
assemblynumber => { type => 'text' },
- audittrail => { type => 'boolean', default => 'false' },
bin_id => { type => 'integer' },
bin_id_ignore_onhand => { type => 'integer' },
businessnumber => { type => 'text' },
class => 'SL::DB::PaymentTerm',
key_columns => { payment_id => 'id' },
},
+
+ salesman => {
+ class => 'SL::DB::Employee',
+ key_columns => { salesman_id => 'id' },
+ },
);
1;
--- /dev/null
+-- @tag: drop_audittrail
+-- @description: Tabelle audittrail wird nicht mehr benutzt
+-- @depends: release_3_0_0
+-- @ignore: 0
+ALTER TABLE defaults DROP COLUMN audittrail;
+DROP TABLE audittrail;
--- /dev/null
+# @tag: employee_id_foreignkeys
+# @description: Falls ein Benutzer hart in der Datenbank gelöscht werden soll, entsprechende Fremdschlüssel setzen, entfernt ferner verwaiste Einträge
+# @depends: release_3_0_0
+package SL::DBUpgrade2::employee_id_foreignkeys;
+
+use utf8;
+
+use parent qw(SL::DBUpgrade2::Base);
+use strict;
+
+sub run {
+ my ($self) = @_;
+
+ # this query will fail if we have orphaned entries
+ # should only occur
+ $self->db_query(qq|UPDATE customer set salesman_id = NULL where salesman_id not in (select id from employee)|, may_fail => 0);
+ $self->db_query(qq|UPDATE vendor set salesman_id = NULL where salesman_id not in (select id from employee)|, may_fail => 0);
+ $self->db_query(qq|ALTER TABLE customer ADD FOREIGN KEY (salesman_id) REFERENCES employee (id)|, may_fail => 0);
+ $self->db_query(qq|ALTER TABLE vendor ADD FOREIGN KEY (salesman_id) REFERENCES employee (id)|, may_fail => 0);
+
+ return 1;
+}
+
+1;