USE zTestMantisbt; GO -- -------------------------------------------------------------------------------- -- MantisBT Version 1.2.19 -- Schema Version 183 -- -------------------------------------------------------------------------------- -- Microsoft SQL Server 2016 (RTM) - 13.0.1601.5 (X64) -- Apr 29 2016 23:23:58 -- Copyright (c) Microsoft Corporation Express Edition (64-bit) on Windows 10 Pro 6.3 (Build 10586: ) -- -------------------------------------------------------------------------------- CREATE TABLE mantis_bug_file_table ( id INT IDENTITY(1,1) NOT NULL, bug_id INT DEFAULT 0 NOT NULL, title VARCHAR(250) DEFAULT '' NOT NULL, description VARCHAR(250) DEFAULT '' NOT NULL, diskfile VARCHAR(250) DEFAULT '' NOT NULL, filename VARCHAR(250) DEFAULT '' NOT NULL, folder VARCHAR(250) DEFAULT '' NOT NULL, filesize INT DEFAULT 0 NOT NULL, file_type VARCHAR(250) DEFAULT '' NOT NULL, date_added DATETIME DEFAULT '1970-01-01 00:00:01' NOT NULL, -- creates semi-randomly named DEFAULT constraint, for example: -- DF__mantis_bu__date___2B3F6F97 content IMAGE NOT NULL, PRIMARY KEY (id) ); CREATE INDEX idx_bug_file_bug_id ON mantis_bug_file_table (bug_id); -- ... other stuff ... CREATE INDEX idx_diskfile ON mantis_bug_file_table (diskfile); -- ... other stuff ... ALTER TABLE mantis_bug_file_table -- DROP COLUMN fails because constraint exists DROP COLUMN date_added; /* Error: Msg 5074, Level 16, State 1, Line 27 The object 'DF__mantis_bu__date___2B3F6F97' is dependent on column 'date_added'. Msg 4922, Level 16, State 9, Line 27 ALTER TABLE DROP COLUMN date_added failed because one or more objects access this column. */ EXEC sp_rename 'mantis_bug_file_table.date_added_int','date_added'; -- ... other stuff ... ALTER TABLE mantis_bug_file_table ADD user_id INT DEFAULT 0 NOT NULL;