Adds a `License` model
This PR part 1 of N to allow Artists to assign a license to an Album.
Ultimately I felt that a configuration table for the license data was a better option than an enum since it would 1) add a hard relational constraint on the association's data and would consolidate important secondary metadata values like label and source all in one place. In other words, a License is a richer domain model than something like a the common type of single value enum such as status. In one practical context, it makes the upcoming changes to the form extremely simple by being able to do:
<%= form.collection_select :license_id, License.all, :id, :label, include_blank: "Select a license" %>
Here's the DML for the license data. I'm not sure what's the preference for how to apply this patch.
insert into licenses (code, source, label, created_at, updated_at)
VALUES('all_rights_reserved', null, 'All Rights Reserved', now(), now()),
('by', 'https://creativecommons.org/licenses/by/4.0/', 'Attribution', now(), now()),
('by_sa', 'https://creativecommons.org/licenses/by-sa/4.0/', 'Attribution-ShareAlike 4.0 International', now(), now()),
('by_nc', 'https://creativecommons.org/licenses/by-nc/4.0/', 'Attribution-NonCommercial', now(), now()),
('by_nc_sa', 'https://creativecommons.org/licenses/by-nc-sa/4.0/', 'Attribution-NonCommercial-ShareAlike', now(), now()),
('by_nd', 'https://creativecommons.org/licenses/by-nd/4.0/', 'Attribution-NoDerivs', now(), now()),
('by_nc_nd', 'https://creativecommons.org/licenses/by-nc-nd/4.0/', 'Attribution-NonCommercial-NoDerivs', now(), now()),
('cc_0', 'https://creativecommons.org/publicdomain/zero/1.0/', 'No Copyright', now(), now())
returning *;
Looks good @rosschapman! I think the data in your PR description could be added to db/seeds.rb under the line that loads the development seeds. We'd be able to run it in production after this PR lands.
Do you intend to add the UI changes to this PR too?
@chrislo I will add the UI changes in a follow-up PR in order to reduce the cognitive load per review and avoid things that are done being held up by congruent discussion (a habit from the job).
I can add data to the seed! That's certainly an expedient setup method. I gather then it won't mess with any build or deployment process.