Media references let Spotify track which codes are scanned, enable them to theoretically re-map codes, and just look better when encoded. Spotify maintains a database of media reference to URI mappings. The media reference is what gets encoded into the barcode and links the barcode to the URI. Media reference #Ī media reference is first generated by Spotify for a Spotify URI. I find it easier to understand Spotify Barcodes by starting with the URI and working through the encoding process. I will include some more resources if you want to keep learning. This article is going to be a little bit more technical than part 1 as I try to explain exactly how Spotify encodes their barcodes. Thanks to a little more digging and a lot of help from someone on Stack Overflow I can now do that conversion. Ludvig Strigeus, a key early developer at Spotify and the person who invented Spotify Codes, even stopped by and shared some more information on their creation and the rationale behind them!Īt the end of part 1 I wrote that I wasn’t sure about some of the details, so I was not able to implement my own barcode to URI converter. I shared it on reddit where it generated a lot of interesting discussion. If you haven’t read that post you should check it out. When creating the table, you may use any of the schema builder's column methods to define the table's columns.In part 1 I dove into Spotify Codes and explained the general technical concepts of how they work. This is primarily useful if your application accumulates many migrations and two of them have a class name collision: id() However, if you wish, you may return an anonymous class from your migration file.
For example, the following migration creates a flights table: id() Īs you may have noticed in the example above, Laravel will automatically assign a class name to all of the migrations that you generate using the make:migration command.
To learn about all of the methods available on the Schema builder, check out its documentation. Within both of these methods, you may use the Laravel schema builder to expressively create and modify tables. The up method is used to add new tables, columns, or indexes to your database, while the down method should reverse the operations performed by the up method. Schema dumps may not be restored to in-memory SQLite databases.Ī migration class contains two methods: up and down. Migration squashing is only available for the MySQL, PostgreSQL, and SQLite databases and utilizes the database's command-line client. The given path should be relative to your application's base path. If you would like to specify a custom path for the generated migration, you may use the -path option when executing the make:migration command. Otherwise, you may simply specify the table in the migration file manually. If Laravel is able to determine the table name from the migration name, Laravel will pre-fill the generated migration file with the specified table. Laravel will use the name of the migration to attempt to guess the name of the table and whether or not the migration will be creating a new table. Each migration filename contains a timestamp that allows Laravel to determine the order of the migrations: php artisan make:migration create_flights_table The new migration will be placed in your database/migrations directory.
You may use the make:migration Artisan command to generate a database migration. Typically, migrations will use this facade to create and modify database tables and columns. The Laravel Schema facade provides database agnostic support for creating and manipulating tables across all of Laravel's supported database systems. If you have ever had to tell a teammate to manually add a column to their local database schema after pulling in your changes from source control, you've faced the problem that database migrations solve. Migrations are like version control for your database, allowing your team to define and share the application's database schema definition.