Sha256: 517b3c968f26d6e358779bc02aef85df29acd7138b39f058b7d163f9afffab03

Contents?: true

Size: 848 Bytes

Versions: 7

Compression:

Stored size: 848 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 Singer < ActiveRecord::Base
  # `albums` is defined as INTERLEAVE IN PARENT `singers`.
  # The primary key of `albums` is (`singerid`, `albumid`).
  has_many :albums, foreign_key: :singerid

  # `tracks` is defined as INTERLEAVE IN PARENT `albums`.
  # The primary key of `tracks` is [`singerid`, `albumid`, `trackid`].
  # The `singerid` column can be used to associate tracks with a singer without the need to go through albums.
  # Note also that the inclusion of `singerid` as a column in `tracks` is required in order to make `tracks` a child
  # table of `albums` which has primary key (`singerid`, `albumid`).
  has_many :tracks, foreign_key: :singerid
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
activerecord-spanner-adapter-2.1.0 examples/snippets/interleaved-tables/models/singer.rb
activerecord-spanner-adapter-2.0.0 examples/snippets/interleaved-tables/models/singer.rb
activerecord-spanner-adapter-1.8.0 examples/snippets/interleaved-tables/models/singer.rb
activerecord-spanner-adapter-1.6.3 examples/snippets/interleaved-tables/models/singer.rb
activerecord-spanner-adapter-1.6.2 examples/snippets/interleaved-tables/models/singer.rb
activerecord-spanner-adapter-1.6.1 examples/snippets/interleaved-tables/models/singer.rb
activerecord-spanner-adapter-1.6.0 examples/snippets/interleaved-tables/models/singer.rb