Drops and re-creates the SQL schema
773848
def init_db():
    
    db.drop_all()
    db.configure_mappers()
    db.create_all()
    db.session.commit()
472793
def scripts_previously_run(scripts)
      if scripts.empty? || !@db.schema_schema_evolution_manager_exists?
        []
      else
        sql = "select filename from %s.%s where filename in (%s)" % [Db.schema_name, @table_name, "'" + scripts.join("', '") + "'"]
        @db.psql_command(sql).strip.split
      end
    end
1225054
public void dropSchema()
    {
        if (operation != null && operation.equalsIgnoreCase("create-drop"))
        {
            try
            {
                HTableDescriptor hTableDescriptor = null;
                if (admin.isTableAvailable(databaseName))
                {
                    if (admin.isTableEnabled(databaseName))
                    {
                        hTableDescriptor = admin.getTableDescriptor(databaseName.getBytes());
                        admin.disableTable(databaseName);
                    }
                    for (TableInfo tableInfo : tableInfos)
                    {
                        if (tableInfo != null && tableInfo.getTableName() != null
                                && hTableDescriptor.getFamily(tableInfo.getTableName().getBytes()) != null)
                        {
                            admin.deleteColumn(databaseName, tableInfo.getTableName());
                        }
                    }
                }
            }
            catch (TableNotFoundException tnfe)
            {
                logger.error("Table doesn't exist, Caused by ", tnfe);
                throw new SchemaGenerationException(tnfe, "Hbase");
            }
            catch (IOException ioe)
            {
                logger.error("Table isn't in enabled state, Caused by", ioe);
                throw new SchemaGenerationException(ioe, "Hbase");
            }
            finally
            {
                try
                {
                    admin.enableTable(databaseName);
                }
                catch (IOException ioe)
                {
                    logger.error("Table isn't in enabled state, Caused by", ioe);
                    throw new SchemaGenerationException(ioe, "Hbase");
                }
            }
        }
        operation = null;
        admin = null;
    }
1027970
public function dropDatabase()
    {
        $dropSchemaSql = $this->getDropDatabaseSQL();
        $conn          = $this->em->getConnection();

        foreach ($dropSchemaSql as $sql) {
            $conn->executeQuery($sql);
        }
    }
254484
def truncate_schema(self):
        

        assert self.server == 'localhost'
        con = self.connection or self._connect()
        self._initialize(con)
        cur = con.cursor()

        cur.execute('DELETE FROM publication;')
        cur.execute('TRUNCATE systems CASCADE;')

        con.commit()
        con.close()

        return
1230226
def clear_schema(self):
        """"""
        execute = self.cursor.execute
        execute('TRUNCATE TABLE gauged_data')
        execute('TRUNCATE TABLE gauged_keys')
        execute('TRUNCATE TABLE gauged_writer_history')
        execute('TRUNCATE TABLE gauged_cache')
        execute('TRUNCATE TABLE gauged_statistics')
        self.db.commit()
1256929
function ( table, columns, drop )
    {
        var addColumn = 'async.series([',
            dropColumn = 'async.series([';
        var aC = util.format( '\ndb.addColumn.bind( db, \'%s\', \'%%s\', { type: \'%%s\'', table );
        var dC = util.format( '\ndb.removeColumn.bind( db, \'%s\', \'%%s\')', table );

        for ( var i = 0; i < columns.length; ++i )
        {
            if ( i > 0 )
                dropColumn += ',';

            dropColumn += util.format( dC, columns[ i ][ 0 ] );
        }

        dropColumn += '], callback);';

        addColumn += this.Columns( aC, columns, ' } ),' );
        addColumn = addColumn.substring( 0, addColumn.length - 1 ) + '], callback);';

        return this.createMigration( addColumn, dropColumn, drop );
    }
978467
def clone_schema(self, base_schema_name, new_schema_name):
        
        connection.set_schema_to_public()
        cursor = connection.cursor()

        # check if the clone_schema function already exists in the db
        try:
            cursor.execute("SELECT 'clone_schema'::regproc")
        except ProgrammingError:
            self._create_clone_schema_function()
            transaction.commit()

        sql = 'SELECT clone_schema(%(base_schema)s, %(new_schema)s, TRUE)'
        cursor.execute(
            sql,
            {'base_schema': base_schema_name, 'new_schema': new_schema_name}
        )
        cursor.close()
189724
void delete() {
        StringBuilder sql = new StringBuilder();
        sql.append("DROP SCHEMA ");
        sql.append(this.sqlgGraph.getSqlDialect().maybeWrapInQoutes(this.name));
        if (this.sqlgGraph.getSqlDialect().supportsCascade()) {
            sql.append(" CASCADE");
        }
        if (this.sqlgGraph.getSqlDialect().needsSemicolon()) {
            sql.append(";");
        }
        if (logger.isDebugEnabled()) {
            logger.debug(sql.toString());
        }
        Connection conn = this.sqlgGraph.tx().getConnection();
        try (Statement stmt = conn.createStatement()) {
            stmt.execute(sql.toString());
        } catch (SQLException e) {
            logger.error("schema deletion failed " + this.sqlgGraph.toString(), e);
            throw new RuntimeException(e);
        }
    }
795720
def clean(self):
        
        self.exec_pg_success(['dropdb', '-U', self.user, self.database])
        self.exec_pg_success(['createdb', '-U', self.user, self.database])
1148809
@Override
    public void dropSchema()
    {
        try
        {
            for (TableInfo tableInfo : tableInfos)
            {
                HttpResponse deleteResponse = null;
                Map<String, MapReduce> views = new HashMap<String, MapReduce>();
                String id = CouchDBConstants.DESIGN + tableInfo.getTableName();
                CouchDBDesignDocument designDocument = getDesignDocument(id);
                designDocument.setLanguage(CouchDBConstants.LANGUAGE);
                views = designDocument.getViews();
                if (views != null)
                {
                    StringBuilder builder = new StringBuilder("rev=");
                    builder.append(designDocument.get_rev());
                    URI uri = new URI(CouchDBConstants.PROTOCOL, null, httpHost.getHostName(), httpHost.getPort(),
                            CouchDBConstants.URL_SEPARATOR + databaseName.toLowerCase()
                                    + CouchDBConstants.URL_SEPARATOR + id, builder.toString(), null);
                    HttpDelete delete = new HttpDelete(uri);
                    try
                    {
                        deleteResponse = httpClient.execute(httpHost, delete, CouchDBUtils.getContext(httpHost));
                    }
                    finally
                    {
                        CouchDBUtils.closeContent(deleteResponse);
                    }
                }
            }
        }
        catch (Exception e)
        {
            logger.error("Error while creating database, caused by {}.", e);
            throw new SchemaGenerationException("Error while creating database", e, "couchDB");
        }
    }
425299
def drop_table(self, cursor, target, options):
        ""
        sql = 'DROP TABLE IF EXISTS {0}'
        cursor.execute(sql.format(self.qualified_names[target]))
43241
def drop_all_tables(self):
        """"""
        for table_name in self.table_names():
            self.execute_sql("DROP TABLE %s" % table_name)
        self.connection.commit()
1313364
def dump_table(self, table, drop_statement=True):
        """"""
        create_statement = self.get_table_definition(table)
        data = self.select_all(table)
        statements = ['\n', sql_file_comment(''),
                      sql_file_comment('Table structure and data dump for {0}'.format(table)), sql_file_comment('')]
        if drop_statement:
            statements.append('\nDROP TABLE IF EXISTS {0};'.format(wrap(table)))
        statements.append('{0};\n'.format(create_statement))
        if len(data) > 0:
            statements.append('{0};'.format(insert_statement(table, self.get_columns(table), data)))
        return '\n'.join(statements)
1284763
private function createSchemaForDownMethod($schema, $meta)
    {
        // If the user created a table, then for the down
        // method, we should drop it.
        if ($meta['action'] == 'create') {
            return sprintf("Schema::drop('%s');", $meta['table']);
        }

        // If the user added columns to a table, then for
        // the down method, we should remove them.
        if ($meta['action'] == 'add') {
            $fields = $this->constructSchema($schema, 'Drop');

            return $this->insert($fields)->into($this->getChangeSchemaWrapper());
        }

        // If the user removed columns from a table, then for
        // the down method, we should add them back on.
        if ($meta['action'] == 'remove') {
            $fields = $this->constructSchema($schema);

            return $this->insert($fields)->into($this->getChangeSchemaWrapper());
        }

        // Otherwise, we have no idea how to proceed.
        throw new GeneratorException;
    }
218486
def drop_db():
    """"""
    local_machine()
    with fab_settings(warn_only=True):
        local('psql {0} -c "DROP DATABASE {1}"'.format(
            USER_AND_HOST, env.db_name))
        local('psql {0} -c "DROP USER {1}"'.format(
            USER_AND_HOST, env.db_role))
926290
def _drop_schema(self, force_drop=False):
        
        connection = connections[get_tenant_database_alias()]
        has_schema = hasattr(connection, 'schema_name')
        if has_schema and connection.schema_name not in (self.schema_name, get_public_schema_name()):
            raise Exception("Can't delete tenant outside it's own schema or "
                            "the public schema. Current schema is %s."
                            % connection.schema_name)

        if has_schema and schema_exists(self.schema_name) and (self.auto_drop_schema or force_drop):
            self.pre_drop()
            cursor = connection.cursor()
            cursor.execute('DROP SCHEMA %s CASCADE' % self.schema_name)