Sha256: aa75242be77b2f20f40f1787a06e1f90a37c232837511b3d5f968f8771ed2927

Contents?: true

Size: 629 Bytes

Versions: 4

Compression:

Stored size: 629 Bytes

Contents

# Copyright 2023 Google LLC
#
# Use of this source code is governed by an MIT-style
# license that can be found in the LICENSE file or at
# https://opensource.org/licenses/MIT.

class Album < ActiveRecord::Base
  # `albums` is defined as INTERLEAVE IN PARENT `singers`.
  # The primary key of `singers` is `singerid`.
  belongs_to :singer, foreign_key: :singerid

  # `tracks` is defined as INTERLEAVE IN PARENT `albums`.
  # The primary key of `albums` is (`singerid`, `albumid`).
  # Rails 7.1 requires using query_constraints to define a composite foreign key.
  has_many :tracks, query_constraints: [:singerid, :albumid]
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-spanner-adapter-1.6.3 examples/snippets/interleaved-tables/models/album.rb
activerecord-spanner-adapter-1.6.2 examples/snippets/interleaved-tables/models/album.rb
activerecord-spanner-adapter-1.6.1 examples/snippets/interleaved-tables/models/album.rb
activerecord-spanner-adapter-1.6.0 examples/snippets/interleaved-tables/models/album.rb