Sha256: 10480f285a9a140e4fb8beba7c71b11896d34b190df93bdf4120780d088fc680

Contents?: true

Size: 710 Bytes

Versions: 3

Compression:

Stored size: 710 Bytes

Contents

# Copyright 2021 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`), but
  # only `albumid` is used by ActiveRecord as the primary key. The `singerid` column is defined as a `parent_key` of
  # `albums` (see also the `db/migrate/01_create_tables.rb` file).
  has_many :tracks, foreign_key: "albumid"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
activerecord-spanner-adapter-0.7.0 examples/snippets/interleaved-tables/models/album.rb
activerecord-spanner-adapter-0.6.0 examples/snippets/interleaved-tables/models/album.rb
activerecord-spanner-adapter-0.5.0 examples/snippets/interleaved-tables/models/album.rb