Skip to content

Instantly share code, notes, and snippets.

View bkahlerventer's full-sized avatar

Bennie Kahler-Venter bkahlerventer

View GitHub Profile
@bkahlerventer
bkahlerventer / InitialDbMigrationCommand.php
Last active May 3, 2016 15:35 — forked from bmarston/InitialDbMigrationCommand.php
Let's say you're starting a new Yii project and you've already created the database schema for it using something like phpMyAdmin or MySQL Workbench. Now you want to create an initial database migration so you can put the schema under version control, but you don't want to manually write the Yii code to create the tables, indexes, and foreign ke…
<?php
class InitialDbMigrationCommand extends CConsoleCommand
{
public function run($args) {
$schema = $args[0];
$tables = Yii::app()->db->schema->getTables($schema);
$addForeignKeys = '';
$dropForeignKeys = '';
@bkahlerventer
bkahlerventer / view.py
Created November 2, 2015 10:06 — forked from techniq/view.py
SQLAlchemy View support
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.sql.expression import Executable, ClauseElement
from sqlalchemy.schema import DDLElement, DropTable
from sqlalchemy.sql import table
from sqlalchemy.orm import Query
from . import db
class CreateView(DDLElement):
{
"template": "logstash-*",
"settings" : {
"number_of_shards" : 1,
"number_of_replicas" : 0,
"index" : {
"query" : { "default_field" : "@message" },
"store" : { "compress" : { "stored" : true, "tv": true } }
}
},