Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move module_files.mimetype to files.media_type #403

Merged
merged 8 commits into from
Feb 18, 2016
Merged

Conversation

mmulich
Copy link
Contributor

@mmulich mmulich commented Feb 3, 2016

This puts the mime-type (aka media type and content type) on the files table.

This adds the db-migrator feature to this project. Please review this part of the pull request carefully.

mmulich added a commit to openstax/cnx-publishing that referenced this pull request Feb 3, 2016
mmulich added a commit to openstax/cnx-publishing that referenced this pull request Feb 3, 2016
@reedstrm
Copy link
Contributor

reedstrm commented Feb 3, 2016

Looking at legacy code, https://github.com/Rhaptos/Products.RhaptosModuleStorage seems to treat the mimetype value as write only, so I think this is even a backwards-compatible change

@karenc
Copy link
Contributor

karenc commented Feb 3, 2016

👍

mmulich added a commit to openstax/cnx-publishing that referenced this pull request Feb 3, 2016
@karenc
Copy link
Contributor

karenc commented Feb 3, 2016

What happens when legacy wants to write to module_files.mimetype? This PR removes the column right?

@reedstrm
Copy link
Contributor

reedstrm commented Feb 3, 2016

I'm preparing a matching PR for RhaptosModuleStorage, which will shift where the mimetype is stored, to match.

@mmulich
Copy link
Contributor Author

mmulich commented Feb 17, 2016

I've split the migration in two. Have another look.

@karenc
Copy link
Contributor

karenc commented Feb 17, 2016

👍

FYI Now that there are two migrations, if you want to just run the first migration, you can do something like:

$ dbmigrator --context cnx-archive --config development.ini migrate --version=20160128110515
Running migration 20160128110515 mimetype_on_files_table                                                                                 
These files (fileid, sha1) do not have a corresponding module_files entry:                                                               
101, a5b4875b9e44ab9cf0332e4588af233d5657d131                                                                                            

---                                                                                                                                      
+++                                                                                                                                      
@@ -1458,21 +1458,22 @@                                                                                                                  
 ALTER TABLE public.document_hits OWNER TO cnxarchive;                                                                                   

 --                                                                                                                                      
 -- Name: files; Type: TABLE; Schema: public; Owner: cnxarchive; Tablespace:                                                             
 --                                                                                                                                      

 CREATE TABLE files (                                                                                                                    
     fileid integer NOT NULL,                                                                                                            
     md5 text,                                                                                                                           
     sha1 text,                                                                                                                          
-    file bytea                                                                                                                          
+    file bytea,                                                                                                                         
+    media_type text                                                                                                                     
 );                                                                                                                                      


 ALTER TABLE public.files OWNER TO cnxarchive;                                                                                           

 --                                                                                                                                      
 -- Name: files_fileid_seq; Type: SEQUENCE; Schema: public; Owner: cnxarchive                                                            
 --                                                                                                                                      

 CREATE SEQUENCE files_fileid_seq                                                                                                        

@reedstrm
Copy link
Contributor

Excellent!

reedstrm added a commit that referenced this pull request Feb 18, 2016
Move module_files.mimetype to files.media_type
@reedstrm reedstrm merged commit 96801e6 into master Feb 18, 2016
@reedstrm reedstrm deleted the mimetype-shuffle branch February 18, 2016 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants