Sha256: 6db8125b481b545325bf2ff27570d60cc8bdcbe0f07e513233ad2365bb7df784

Contents?: true

Size: 686 Bytes

Versions: 6

Compression:

Stored size: 686 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.

require "composite_primary_keys"

class Album < ActiveRecord::Base
  # Register both primary key columns with composite_primary_keys
  self.primary_keys = :singerid, :albumid

  # The relationship with singer is not really a foreign key, but an INTERLEAVE IN relationship. We still need to
  # use the `foreign_key` attribute to indicate which column to use for the relationship.
  belongs_to :singer, foreign_key: :singerid
  has_many :tracks, foreign_key: [:singerid, :albumid], dependent: :delete_all
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-spanner-adapter-1.4.1 acceptance/models/album.rb
activerecord-spanner-adapter-1.4.0 acceptance/models/album.rb
activerecord-spanner-adapter-1.3.1 acceptance/models/album.rb
activerecord-spanner-adapter-1.2.2 acceptance/models/album.rb
activerecord-spanner-adapter-1.2.1 acceptance/models/album.rb
activerecord-spanner-adapter-1.2.0 acceptance/models/album.rb