From 52675d113da4b61d1c05ab1985acf9341d9172bd Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Wed, 24 Apr 2024 09:59:11 -0400 Subject: [PATCH] SQL FKs --- .gitignore | 2 ++ ...igration_10_Alter_Tables_For_Relations.asp | 20 ++++++++++++++ ...ation_11_Alter_Tables_For_Relations_FK.asp | 27 +++++++++++++++++++ Data/Migrations/migrate.asp | 6 +++-- 4 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Data/Migrations/Migration_10_Alter_Tables_For_Relations.asp create mode 100644 Data/Migrations/Migration_11_Alter_Tables_For_Relations_FK.asp diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7874d74 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.csv +*.mdb \ No newline at end of file diff --git a/Data/Migrations/Migration_10_Alter_Tables_For_Relations.asp b/Data/Migrations/Migration_10_Alter_Tables_For_Relations.asp new file mode 100644 index 0000000..3f3945a --- /dev/null +++ b/Data/Migrations/Migration_10_Alter_Tables_For_Relations.asp @@ -0,0 +1,20 @@ +<% +Class Migration_10_Alter_Tables_For_Relations + Public Migration + + Public Sub Up + Migration.Do "ALTER TABLE [InkjetRecords] " &_ + "ALTER COLUMN [KitID] LONG;" + Migration.Do "ALTER TABLE [KitLabels] " &_ + "ALTER COLUMN [KitID] LONG;" +End Sub + + Public Sub Down + Migration.Do "ALTER TABLE [InkjetRecords] " &_ + "ALTER COLUMN [KitID] NUMBER;" + Migration.Do "ALTER TABLE [KitLabels] " &_ + "ALTER COLUMN [KitID] NUMBER;" + End Sub +End Class + Migrations.Add "Migration_10_Alter_Tables_For_Relations" + %> \ No newline at end of file diff --git a/Data/Migrations/Migration_11_Alter_Tables_For_Relations_FK.asp b/Data/Migrations/Migration_11_Alter_Tables_For_Relations_FK.asp new file mode 100644 index 0000000..0a5ad16 --- /dev/null +++ b/Data/Migrations/Migration_11_Alter_Tables_For_Relations_FK.asp @@ -0,0 +1,27 @@ +<% +Class Migration_11_Alter_Tables_For_Relations_FK + Public Migration + + Public Sub Up + Migration.Do "ALTER TABLE [InkjetRecords] ADD CONSTRAINT [KitInkjetRecords]" &_ + " FOREIGN KEY ( [KitID] )" &_ + " REFERENCES [Kit] ( [ID] )" &_ + " ON UPDATE CASCADE" &_ + " ON DELETE CASCADE;" + + Migration.Do "ALTER TABLE [KitLabels] ADD CONSTRAINT [KitKitLabels]" &_ + " FOREIGN KEY ( [KitID] )" &_ + " REFERENCES [Kit] ( [ID] )" &_ + " ON UPDATE CASCADE" &_ + " ON DELETE CASCADE;" +End Sub + + Public Sub Down + Migration.Do "ALTER TABLE [InkjetRecords] " &_ + "DROP CONSTRAINT [KitInkjetRecords];" + Migration.Do "ALTER TABLE [KitLabels] " &_ + "DROP CONSTRAINT [KitKitLabels];" + End Sub +End Class + Migrations.Add "Migration_11_Alter_Tables_For_Relations_FK" + %> \ No newline at end of file diff --git a/Data/Migrations/migrate.asp b/Data/Migrations/migrate.asp index 76a5f87..eed956c 100644 --- a/Data/Migrations/migrate.asp +++ b/Data/Migrations/migrate.asp @@ -24,8 +24,8 @@ End Sub 'TODO: This can be refactored by not having the individual migration files auto-add themselves, but then this file must manually add each one using a slightly dIfferent ' naming convention, i.e. given include file 01_Create_Users.asp the command would be Migrations.Add "Migration_01_Create_Users" or such. At least this way is automated. -'Migrations.Initialize "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata - Copy.mdb;" - Migrations.Initialize "Provider=SQLOLEDB;Server=danielsubuntu,15789;Database=tracking;UID=sa;PWD=SunBrightShine!;" +Migrations.Initialize "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata - Copy.mdb;" + 'Migrations.Initialize "Provider=SQLOLEDB;Server=danielsubuntu,15789;Database=tracking;UID=sa;PWD=SunBrightShine!;" Migrations.Tracing = false %> @@ -38,6 +38,8 @@ Migrations.Tracing = false + + <% Sub HandleMigration putl "Starting Version: " & Migrations.Version & ""