vapor / fluent-kit

Swift ORM (queries, models, and relations) for NoSQL and SQL databases
MIT License
218 stars 116 forks source link

Support multi-column foreign key constraint in `SchemaBuilder` #507

Closed stevapple closed 2 years ago

stevapple commented 2 years ago

This adds the missing multi-column foreign key constraint support to SchemaBuilder.

Now you can create foreign key constraints that reference multiple fields when building the schema:

db.schema("planets")
    .field("galaxy_id", .int64)
    .field("galaxy_name", .string)
    .foreignKey(
        ["galaxy_id", "galaxy_name"],
        references: "galaxies", ["id", "name"]
    )
    .create()
codecov-commenter commented 2 years ago

Codecov Report

Merging #507 (3a1a6c5) into main (8958da5) will increase coverage by 2.41%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #507      +/-   ##
==========================================
+ Coverage   39.74%   42.16%   +2.41%     
==========================================
  Files         106       97       -9     
  Lines        5681     5284     -397     
==========================================
- Hits         2258     2228      -30     
+ Misses       3423     3056     -367     
Flag Coverage Δ
unittests 42.16% <100.00%> (+2.41%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Sources/FluentKit/Schema/SchemaBuilder.swift 66.98% <100.00%> (+5.02%) :arrow_up:
Sources/FluentBenchmark/SolarSystem/Tag.swift
Sources/FluentBenchmark/SolarSystem/Governor.swift
Sources/FluentBenchmark/SolarSystem/Moon.swift
...rces/FluentBenchmark/SolarSystem/SolarSystem.swift
Sources/FluentBenchmark/SolarSystem/Star.swift
Sources/FluentBenchmark/FluentBenchmarker.swift
Sources/FluentBenchmark/SolarSystem/Galaxy.swift
Sources/FluentBenchmark/SolarSystem/Planet.swift
...ources/FluentBenchmark/SolarSystem/PlanetTag.swift
0xTim commented 2 years ago

Going to wait until #509 is released before seeing how that affects this

stevapple commented 2 years ago

Superseded by #509