ajcastro / fk-adder Goto Github PK
View Code? Open in Web Editor NEWLets you add foreign keys smart and easy!
Home Page: http://ajcastro.github.io/fk-adder/
License: MIT License
Lets you add foreign keys smart and easy!
Home Page: http://ajcastro.github.io/fk-adder/
License: MIT License
Delete the created foreign keys. The list of foreign keys can be retrieved from the json files created by Fk::migrate()
described in issue #3
For example we are developing a blog app. The tables involved are users
, tags
and posts
tables.
Migration Files:
20180101_create_users_table
$table->increments('id');
$table->string('name');
20180101_create_tags_table
$table->increments('id');
$table->string('name');
20180101_create_posts_table
$table->increments('id');
Fk::make($table)->add('user_id');
Fk::make($table)->add('tag_id');
$table->string('title');
$table->string('body');
This should generate a json of data that is needed when deleting the foreign key.
Those json files will be saved in directory database/foreign_keys/
and the json filename would be the migration_file_name.json
.
So when we run the above migration it will create a file database/foreign_keys/20180101_create_posts_table.json
. One json file per migration file. Only 20180101_create_posts_table.json
is created because it is the only migration file that calls Fk::make()
.
The data needed to drop a foreign key is the:
Schema::table('posts', function ($table) {
$table->dropForeignKey('the_foreign_key_name');
});
Sample json file format:
[{
"table" : "posts",
"foreign_key_names: ["posts_user_id_foreign_key", "posts_tag_id_foreign_key"]
}]
It is an array of objects, because it can be possible that one migration file can involve many tables.
The code will be placed in the Fk::migrate()
method.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.