Giter Site home page Giter Site logo

build-your-own-backend's People

Watchers

 avatar  avatar

build-your-own-backend's Issues

Not allowing songs to have an id that connects to albums

Background

  • I updated initial migration to add a foreign key in 'song' referencing album_id
  • Did so by rollback to edit initial migration

The Problem

  • With how the seed file was initially made (with an albums_id key in songs that would ideally connect song to album), now it's throwing an error that it doesn't fit constraints of foreign key
  • Because of this error, the data was not updating to database
  • Comment the line out where it declares songs to have the key of albums_id (in the seed file), and everything works besides now there's nothing connecting the two tables (I think)

Screenshots
Screen Shot 2019-11-24 at 1 25 24 PM

Screen Shot 2019-11-24 at 2 48 50 PM

Migration/Schema relationship

What's Wrong

  • Within songs schema, there is no relationship addition to link songs to albums (should be based on album_id)

Why it's not fixed yet

  • Cannot figure out how to reliably edit the column to include foreign/references
  • Don't want to delete & redo database incase there is a fix that doesn't require this

Next steps

Either:

  • figure out a way to edit column without having
    Or:
  • delete/redo the database all together, which is very not ideal

Solution (within migration file in the songs schema) will end up adding something like:

table.integer('album_id').unsigned()
table.foreign('album_id').references('album.id')

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.