public function testDropSchema() { $schema = $this->createShopSchema(); $synchronizer = new SQLAzureSchemaSynchronizer($this->conn, $this->sm); $synchronizer->dropAllSchema(); $synchronizer->createSchema($schema); $sql = $synchronizer->getDropSchema($schema); $this->assertEQuals(5, count($sql)); }
public function testSharding() { $schema = $this->createShopSchema(); $synchronizer = new SQLAzureSchemaSynchronizer($this->conn, $this->sm); $synchronizer->dropAllSchema(); $synchronizer->createSchema($schema); $this->sm->selectShard(0); $this->conn->insert("Products", array("ProductID" => 1, "SupplierID" => 2, "ProductName" => "Test", "Price" => 10.45)); $this->conn->insert("Customers", array("CustomerID" => 1, "CompanyName" => "Foo", "FirstName" => "Benjamin", "LastName" => "E.")); $query = "SELECT * FROM Products"; $data = $this->conn->fetchAll($query); $this->assertTrue(count($data) > 0); $query = "SELECT * FROM Customers"; $data = $this->conn->fetchAll($query); $this->assertTrue(count($data) > 0); $data = $this->sm->queryAll("SELECT * FROM Customers"); $this->assertTrue(count($data) > 0); }
$products->addColumn('Price', 'decimal', array('scale' => 2, 'precision' => 12)); $products->setPrimaryKey(array('ProductID')); $products->addOption('azure.federated', true); $customers = $schema->createTable('Customers'); $customers->addColumn('CustomerID', 'integer'); $customers->addColumn('CompanyName', 'string'); $customers->addColumn('FirstName', 'string'); $customers->addColumn('LastName', 'string'); $customers->setPrimaryKey(array('CustomerID')); $customers->addOption('azure.federated', true); $customers->addOption('azure.federatedOnColumnName', 'CustomerID'); $orders = $schema->createTable('Orders'); $orders->addColumn('CustomerID', 'integer'); $orders->addColumn('OrderID', 'integer'); $orders->addColumn('OrderDate', 'datetime'); $orders->setPrimaryKey(array('CustomerID', 'OrderID')); $orders->addOption('azure.federated', true); $orders->addOption('azure.federatedOnColumnName', 'CustomerID'); $orderItems = $schema->createTable('OrderItems'); $orderItems->addColumn('CustomerID', 'integer'); $orderItems->addColumn('OrderID', 'integer'); $orderItems->addColumn('ProductID', 'integer'); $orderItems->addColumn('Quantity', 'integer'); $orderItems->setPrimaryKey(array('CustomerID', 'OrderID', 'ProductID')); $orderItems->addOption('azure.federated', true); $orderItems->addOption('azure.federatedOnColumnName', 'CustomerID'); // Create the Schema + Federation: $synchronizer = new SQLAzureSchemaSynchronizer($conn, $shardManager); // Or jut look at the SQL: echo implode("\n", $synchronizer->getCreateSchema($schema)); $synchronizer->createSchema($schema);