database-schema

Is it OK to update a production database with EF migrations?

雨燕双飞 提交于 2019-11-27 00:00:54
问题 According to this blog post most companies using EF Migrations are supposedly not updating the database schema of production databases with EF migrations. Instead the blog post's author recommends to use Schema update scripts as part of the deployment process. I've used Schema update scripts for a few years now and while they work, I was planning to use EF migrations instead in the future for the following reasons: Faster deployment, less downtime A simpler deployment procedure Much easier

Migrating ManyToManyField to null true, blank true, isn't recognized

走远了吗. 提交于 2019-11-26 23:01:35
问题 I have made a model change from standard = models.ManyToManyField(Standard) to standard = models.ManyToManyField(Standard, blank=True, null=True) South schemamigration for this app doesn't recognize the change? Similar to this question, which is unanswered: South migrations and changes to many-to-may fields 回答1: That behavior is correct: null doesn't mean anything at the database level when used with a ManyToManyField . The declaration of a ManyToManyField causes the creation of an

Updating database schema with Entity Framework Code First

允我心安 提交于 2019-11-26 21:17:07
问题 Entity Framework Code First is a great framework for developing new projects. But what about extending an existing database? For instance what if I simply want to add an additional property to an existing data entity? Is there any "code first" way to do this or will I have to add a database column by hand using SQL Server Management Studio or a similar tool? All I have found so far is how to regenerate the entire database from scratch when the schema changes, but I don't want to lose my data.

How to get all columns' names for all the tables in MySQL?

青春壹個敷衍的年華 提交于 2019-11-26 21:16:15
Is there a fast way of getting all column names from all tables in MySQL , without having to list all the tables? select * from information_schema.columns where table_schema = 'your_db' order by table_name,ordinal_position suganya To list all the fields from a table in MySQL: select * from information_schema.columns where table_schema = 'your_DB_name' and table_name = 'Your_tablename' SELECT * FROM information_schema.columns WHERE table_schema = DATABASE() ORDER BY table_name, ordinal_position Since I don't have enough rep to comment, here's a minor improvement (in my view) over nick rulez's

How to store arrays in MySQL?

房东的猫 提交于 2019-11-26 21:15:13
I have two tables in MySQL. Table Person has the following columns: id | name | fruits The fruits column may hold null or an array of strings like ('apple', 'orange', 'banana'), or ('strawberry'), etc. The second table is Table Fruit and has the following three columns: ____________________________ fruit_name | color | price ____________________________ apple | red | 2 ____________________________ orange | orange | 3 ____________________________ ...,... So how should I design the fruits column in the first table so that it can hold array of strings that take values from the fruit_name column

How can I initialize a MySQL database with schema in a Docker container?

≡放荡痞女 提交于 2019-11-26 19:23:17
I am trying to create a container with a MySQL database and add a schema to these database. My current Dockerfile is: FROM mysql MAINTAINER (me) <email> # Copy the database schema to the /data directory COPY files/epcis_schema.sql /data/epcis_schema.sql # Change the working directory WORKDIR data CMD mysql -u $MYSQL_USER -p $MYSQL_PASSWORD $MYSQL_DATABASE < epcis_schema.sql In order to create the container I am following the documentation provided on Docker and executing this command: docker run --name ${CONTAINER_NAME} -e MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD} -e MYSQL_USER=${DB_USER} -e

How to rollback a specific migration?

不羁的心 提交于 2019-11-26 19:10:36
I have the following migration file db\migrate\20100905201547_create_blocks.rb How can I specifically rollback that migration file? Zachary Wright rake db:rollback STEP=1 Is a way to do this, if the migration you want to rollback is the last one applied. You can substitute 1 for however many migrations you want to go back. For example: rake db:rollback STEP=5 Will also rollback all the migration that happened later (4, 3, 2 and also 1). To roll back all migrations back to (and including) a target migration, use: (This corrected command was added AFTER all the comments pointing out the error in

Is shortening MongoDB property names worthwhile?

断了今生、忘了曾经 提交于 2019-11-26 18:58:56
In Blog rolling with mongoDB, express and Node.js the author mentions it's a good idea to shorten property names: ....oft-reported issue with mongoDB is the size of the data on the disk... each and every record stores all the field-names .... This means that it can often be more space-efficient to have properties such as 't', or 'b' rather than 'title' or 'body', however for fear of confusion I would avoid this unless truly required! I am aware of solutions of how to do it. I am more interested in when is this truly required? To quote Donald Knuth : Premature optimization is the root of all

When to use MyISAM and InnoDB? [duplicate]

ⅰ亾dé卋堺 提交于 2019-11-26 18:10:47
This question already has an answer here: MyISAM versus InnoDB [closed] 25 answers MyISAM is designed with the idea that your database is queried far more than its updated and as a result it performs very fast read operations. If your read to write(insert|update) ratio is less than 15% its better to use MyISAM. InnoDB uses row level locking, has commit, rollback, and crash-recovery capabilities to protect user data. It supports transaction and fault tolerance above differences is correct between MyISAM and InnobDB? please guide if any other limitations are there for MYISAM and InnobDB. when

Difference Between Schema / Database in MySQL

青春壹個敷衍的年華 提交于 2019-11-26 18:09:36
Is there a difference between a schema and a database in MySQL? In SQL Server, a database is a higher level container in relation to a schema. I read that Create Schema and Create Database do essentially the same thing in MySQL, which leads me to believe that schemas and databases are different words for the same objects. As defined in the MySQL Glossary : In MySQL, physically, a schema is synonymous with a database . You can substitute the keyword SCHEMA instead of DATABASE in MySQL SQL syntax, for example using CREATE SCHEMA instead of CREATE DATABASE . Some other database products draw a