====== pears.PersonWillingness ======
Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.
===== Description =====
Peak Integration - how willing is someone to work. Generated by 3rd party and sent to IQX
===== Columns =====
^ Column ^ Type ^ Null ^ Default ^ Comment ^
| **PersonID** | char(20) | NOT NULL | | |
| Willingness | smallint | NULL | | |
| WhenUpdated | timestamp | NOT NULL | current timestamp | |
===== Primary Key =====
* PersonID
===== Foreign Keys =====
^ Constraint ^ Columns ^ References ^ Delete/update action ^
| person | PersonID | [[database:tables:pears_person|pears.Person (personid)]] | NOT NULL; ON DELETE CASCADE |
===== Referenced By =====
* No incoming foreign keys found.
===== Indexes =====
* No indexes found.
===== Triggers =====
^ Name ^ Timing ^ Event ^
| WillingnessHistoryUpdate | after | update of "Willingness" order 1 |
| WillingnessHistoryDelete | after | delete order 1 |
===== Original SQL =====
-- IQX database structure split by table
-- Source: IQXDatabaseStructure - with comments.sql
-- Table: "pears"."PersonWillingness"
-- Table comment: Peak Integration - how willing is someone to work. Generated by 3rd party and sent to IQX
-- Statement count: 7
CREATE TABLE "pears"."PersonWillingness" (
"PersonID" char(20) NOT NULL
,"Willingness" smallint NULL
,"WhenUpdated" timestamp NOT NULL DEFAULT current timestamp
,PRIMARY KEY ("PersonID" ASC)
)
go
COMMENT ON TABLE "pears"."PersonWillingness" IS
'Peak Integration - how willing is someone to work. Generated by 3rd party and sent to IQX'
go
ALTER TABLE "pears"."PersonWillingness"
ADD NOT NULL FOREIGN KEY "person" ("PersonID" ASC)
REFERENCES "pears"."Person" ("personid")
ON DELETE CASCADE
go
create trigger "WillingnessHistoryUpdate" after update of "Willingness"
order 1 on "pears"."PersonWillingness"
referencing old as "oldrec" new as "newrec"
for each row
when("isnull"("oldrec"."Willingness",11) <> "newrec"."Willingness")
begin
insert into "PersonWillingnessHistory"( "PersonID","Willingness" ) values( "oldrec"."PersonID","newrec"."Willingness" )
end
go
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."PersonWillingness"."WillingnessHistoryUpdate" IS
{create trigger WillingnessHistoryUpdate
after update of "Willingness"
order 1 on "pears"."PersonWillingness"
referencing old as "oldrec" new as "newrec"
for each row
when("isnull"("oldrec"."Willingness",11) <> "newrec"."Willingness")
begin
insert into "PersonWillingnessHistory"( "PersonID","Willingness" ) values( "oldrec"."PersonID","newrec"."Willingness" )
end
}
go
create trigger "WillingnessHistoryDelete" after delete order 1 on
"pears"."PersonWillingness"
referencing old as "oldrec"
for each row
begin
insert into "PersonWillingnessHistory"( "PersonID","Willingness" ) values( "oldrec"."PersonID",null )
end
go
COMMENT TO PRESERVE FORMAT ON TRIGGER "pears"."PersonWillingness"."WillingnessHistoryDelete" IS
{create trigger WillingnessHistoryDelete
after delete order 1 on
"pears"."PersonWillingness"
referencing old as "oldrec"
for each row
begin
insert into "PersonWillingnessHistory"( "PersonID","Willingness" ) values( "oldrec"."PersonID",null )
end
}
go