Index: src/wp-admin/includes/schema.php
===================================================================
--- src/wp-admin/includes/schema.php	(revision 30402)
+++ src/wp-admin/includes/schema.php	(working copy)
@@ -398,6 +398,7 @@
 	'comment_moderation' => 0,
 	'moderation_notify' => 1,
 	'permalink_structure' => '',
+	'rewrite_rules' => '',
 	'gzipcompression' => 0,
 	'hack_file' => 0,
 	'blog_charset' => 'UTF-8',
Index: src/wp-includes/rewrite.php
===================================================================
--- src/wp-includes/rewrite.php	(revision 30402)
+++ src/wp-includes/rewrite.php	(working copy)
@@ -2043,7 +2043,7 @@
 	 * @param bool $hard Whether to update .htaccess (hard flush) or just update rewrite_rules option (soft flush). Default is true (hard).
 	 */
 	public function flush_rules($hard = true) {
-		delete_option('rewrite_rules');
+		update_option( 'rewrite_rules', '' );
 		$this->wp_rewrite_rules();
 		/**
 		 * Filter whether a "hard" rewrite rule flush should be performed when requested.
Index: tests/phpunit/tests/rewrite.php
===================================================================
--- tests/phpunit/tests/rewrite.php	(revision 30402)
+++ tests/phpunit/tests/rewrite.php	(working copy)
@@ -120,4 +120,21 @@
 
 		restore_current_blog();
 	}
-}
\ No newline at end of file
+
+	/*
+	 * @ticket 29107
+	 */
+	function test_function_rules_option_noempty() {
+		global $wp_rewrite;
+
+		$wp_rewrite->set_permalink_structure( '' );
+		$wp_rewrite->flush_rules();
+		$wp_rewrite->set_permalink_structure( '/%postname%/' );
+		$wp_rewrite->flush_rules();
+
+		$rewrite_rules = get_option( 'rewrite_rules' );
+
+		$this->assertTrue( is_array( $rewrite_rules ) );
+		$this->assertNotEmpty( $rewrite_rules );
+	}
+}
