Added foreign keys to the DB tables of access and refresh token scopes.

Change-Id: I39d1e606d5f6890bfccba918df8f44877c938079
diff --git a/full/Changes b/full/Changes
index 43369bc..18e0aea 100644
--- a/full/Changes
+++ b/full/Changes
@@ -2,6 +2,7 @@
 
 2022-03-03
  - Removed VCLoader.
+ - Added foreign keys to the DB tables of access and refresh token scopes.
 
 # version 0.65.1
 
diff --git a/full/src/main/resources/db/sqlite/V1.10__oauth2_alteration.sql b/full/src/main/resources/db/sqlite/V1.10__oauth2_alteration.sql
new file mode 100644
index 0000000..2cedafa
--- /dev/null
+++ b/full/src/main/resources/db/sqlite/V1.10__oauth2_alteration.sql
@@ -0,0 +1,36 @@
+CREATE TABLE IF NOT EXISTS oauth2_refresh_token_scope_new (
+	token_id INTEGER NOT NULL, 
+	scope_id VARCHAR(100) NOT NULL, 
+	FOREIGN KEY (token_id)
+	   REFERENCES oauth2_refresh_token(id)
+	   ON DELETE CASCADE
+	FOREIGN KEY (scope_id)
+	   REFERENCES oauth2_access_scope(id)
+	   ON DELETE CASCADE
+	CONSTRAINT primary_key PRIMARY KEY (token_id, scope_id)
+);
+
+INSERT INTO oauth2_refresh_token_scope_new SELECT * FROM oauth2_refresh_token_scope;
+
+DROP TABLE oauth2_refresh_token_scope;
+
+ALTER TABLE oauth2_refresh_token_scope_new RENAME TO oauth2_refresh_token_scope;
+
+
+CREATE TABLE IF NOT EXISTS oauth2_access_token_scope_new (
+	token_id INTEGER NOT NULL, 
+	scope_id VARCHAR(100) NOT NULL, 
+	FOREIGN KEY (token_id)
+	   REFERENCES oauth2_access_token(id)
+	   ON DELETE CASCADE
+	FOREIGN KEY (scope_id)
+	   REFERENCES oauth2_access_scope(id)
+	   ON DELETE CASCADE
+	CONSTRAINT primary_key PRIMARY KEY (token_id, scope_id)
+);
+
+INSERT INTO oauth2_access_token_scope_new SELECT * FROM oauth2_access_token_scope;
+
+DROP TABLE oauth2_access_token_scope;
+
+ALTER TABLE oauth2_access_token_scope_new RENAME TO oauth2_access_token_scope;