Project

General

Profile

« Previous | Next » 

Revision 2112

Added by Duane Costa over 20 years ago

Correct minor problems with foreign keys in Harvester tables

View differences:

src/xmltables_postgres.sql
311 311
  status                 INT8,          -- non-zero indicates an error status
312 312
  message                VARCHAR(1000), -- text message for this log entry
313 313
  harvest_operation_code VARCHAR(30),   -- the type of harvest operation
314
  site_schedule_id       INT8,          -- foreign key
315
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id),
316
  CONSTRAINT harvest_log_site_schedule_id_fk 
317
        FOREIGN KEY (site_schedule_id) REFERENCES harvest_site_schedule
314
  site_schedule_id       INT8,          -- site schedule id, or 0 if no site
315
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
318 316
);
319 317

  
320 318
/* 
......
331 329
  error_message          VARCHAR(1000), -- text error message
332 330
  document_type          VARCHAR(100),  -- document type
333 331
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
334
  CONSTRAINT harvest_detail_log_harvest_log_id_fk 
332
  CONSTRAINT harvest_detail_log_fk 
335 333
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
336 334
);
337 335

  
src/upgrade-db-to-1.4.sql
70 70
  status                 NUMBER,         -- non-zero indicates an error status
71 71
  message                VARCHAR2(1000), -- text message for this log entry
72 72
  harvest_operation_code VARCHAR2(30),   -- the type of harvest operation
73
  site_schedule_id       NUMBER,         -- foreign key
74
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id),
75
  CONSTRAINT harvest_log_site_schedule_id_fk 
76
        FOREIGN KEY (site_schedule_id) REFERENCES harvest_site_schedule
73
  site_schedule_id       NUMBER,         -- site schedule id, or 0 if no site
74
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
77 75
);
78 76

  
79 77
/* 
......
90 88
  error_message          VARCHAR2(1000), -- text error message
91 89
  document_type          VARCHAR2(100),  -- document type
92 90
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
93
  CONSTRAINT harvest_detail_log_harvest_log_id_fk 
91
  CONSTRAINT harvest_detail_log_fk 
94 92
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
95 93
);
96 94

  
src/xmltables.sql
346 346
    INTO :new.entryid
347 347
    FROM dual;
348 348
END;
349
/
349 350

  
350 351
/* 
351 352
 * harvest_site_schedule -- table to store harvest sites and schedule info
......
372 373
  status                 NUMBER,         -- non-zero indicates an error status
373 374
  message                VARCHAR2(1000), -- text message for this log entry
374 375
  harvest_operation_code VARCHAR2(30),   -- the type of harvest operation
375
  site_schedule_id       NUMBER,         -- foreign key
376
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id),
377
  CONSTRAINT harvest_log_site_schedule_id_fk 
378
        FOREIGN KEY (site_schedule_id) REFERENCES harvest_site_schedule
376
  site_schedule_id       NUMBER,         -- site schedule id, or 0 if no site
377
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
379 378
);
380 379

  
381 380
/* 
......
392 391
  error_message          VARCHAR2(1000), -- text error message
393 392
  document_type          VARCHAR2(100),  -- document type
394 393
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
395
  CONSTRAINT harvest_detail_log_harvest_log_id_fk 
394
  CONSTRAINT harvest_detail_log_fk 
396 395
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
397 396
);
398 397

  
src/xmltables-sqlserver.sql
456 456
	)
457 457
GO
458 458

  
459
ALTER TABLE [dbo].[harvest_log] ADD 
460
	CONSTRAINT [FK_harvest_log_harvest_site_schedule] FOREIGN KEY 
461
	(
462
		[site_schedule_id]
463
	) REFERENCES [dbo].[harvest_site_schedule] (
464
		[site_schedule_id]
465
	)
466
GO
467

  
468 459
ALTER TABLE [dbo].[harvest_detail_log] ADD 
469 460
	CONSTRAINT [FK_harvest_detail_log_harvest_log] FOREIGN KEY 
470 461
	(
src/upgrade-db-to-1.4_postgres.sql
61 61
  status                 INT8,          -- non-zero indicates an error status
62 62
  message                VARCHAR(1000), -- text message for this log entry
63 63
  harvest_operation_code VARCHAR(30),   -- the type of harvest operation
64
  site_schedule_id       INT8,          -- foreign key
65
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id),
66
  CONSTRAINT harvest_log_site_schedule_id_fk 
67
        FOREIGN KEY (site_schedule_id) REFERENCES harvest_site_schedule
64
  site_schedule_id       INT8,          -- site schedule id, or 0 if no site
65
  CONSTRAINT harvest_log_pk PRIMARY KEY (harvest_log_id)
68 66
);
69 67

  
70 68
/* 
......
81 79
  error_message          VARCHAR(1000), -- text error message
82 80
  document_type          VARCHAR(100),  -- document type
83 81
  CONSTRAINT harvest_detail_log_pk PRIMARY KEY (detail_log_id),
84
  CONSTRAINT harvest_detail_log_harvest_log_id_fk 
82
  CONSTRAINT harvest_detail_log_fk 
85 83
        FOREIGN KEY (harvest_log_id) REFERENCES harvest_log
86 84
);
87 85

  

Also available in: Unified diff