Improved style of SQL
-CREATE TABLE packages(
+CREATE TABLE packages
+(
id BIGSERIAL PRIMARY KEY,
package_name TEXT NOT NULL,
forge TEXT NOT NULL,
@@ -7,7 +8,8 @@ CREATE TABLE packages(
created_at TIMESTAMP
);
-CREATE TABLE package_versions(
+CREATE TABLE package_versions
+(
id BIGSERIAL PRIMARY KEY,
package_id BIGINT NOT NULL REFERENCES packages (id),
version TEXT NOT NULL,
@@ -16,13 +18,15 @@ CREATE TABLE package_versions(
metadata JSONB
);
-CREATE TABLE dependencies(
+CREATE TABLE dependencies
+(
package_version_id BIGINT NOT NULL REFERENCES package_versions (id),
dependency_id BIGINT NOT NULL REFERENCES packages (id),
version_range TEXT[] NOT NULL
);
-CREATE TABLE modules(
+CREATE TABLE modules
+(
id BIGSERIAL PRIMARY KEY,
package_version_id BIGINT NOT NULL REFERENCES package_versions (id),
namespaces TEXT NOT NULL,
@@ -31,7 +35,8 @@ CREATE TABLE modules(
metadata JSONB
);
-CREATE TABLE callables(
+CREATE TABLE callables
+(
id BIGSERIAL PRIMARY KEY,
module_id BIGINT REFERENCES modules (id),
fasten_uri TEXT NOT NULL,
@@ -40,7 +45,8 @@ CREATE TABLE callables(
metadata JSONB
);
-CREATE TABLE edges(
+CREATE TABLE edges
+(
source_id BIGINT NOT NULL REFERENCES callables (id),
target_id BIGINT NOT NULL REFERENCES callables (id),
metadata JSONB
